FileNotFound异常,但文件在那里

Cac*_*oon 0 c# image file

没有太多的解释,因为我没有合理的解释为什么这不起作用:s 在此输入图像描述

只是为了确认,这是一个'jpeg'文件扩展,名称是正确的,我没有看到任何其他问题,为什么它将无法找到.

Jon*_*eet 6

您将其保存为以"jpg"结尾的文件名,然后从以"jpeg"结尾的文件名加载.假设您正在尝试加载刚刚保存的文件,那就是问题所在.

(我会复制代码以指出有问题的行,但您只将其作为图像包含在内...)

我强烈建议一次构建文件名,并使用该变量两次:

// I prefer using Path.Combine over string concatenation, but both will work.
// You might want to change "Identitys" to "Identities" though :)
string file = Path.Combine(@"C:\", "SimpleSkype", "Identitys", dd + ".jpg");
SaveSkypeAvatarToDisk(u.Handle, file);
using (Image image = Image.FromFile(file))
{
    ...
}
Run Code Online (Sandbox Code Playgroud)