【问题标题】:Image.FromFile, Not found [But its there]Image.FromFile,未找到 [但它在那里]
【发布时间】:2013-07-29 03:38:22
【问题描述】:

正如我所说的那样奇怪。 o.0.

我已经检查并再次检查,甚至不明白为什么它不起作用......

这里是使用的代码:

try {
    if (!(Directory.Exists(@"C:\SimpleSkype\Identitys")))
        Directory.CreateDirectory(@"C:\SimpleSkype\Identitys");
    //Regex rgx = new Regex("[^a-zA-Z0-9  -]");
    //String dd = rgx.Replace(u.Handle, "");
    string file = Path.Combine(@"C:\", "SimpleSkype", "Identitys", "victim.jpg");
    SaveSkypeAvatarToDisk(u.Handle, file);
    using (Image image = Image.FromFile(@"C:\SimpleSkype\Identitys\victim.jpg")) {
        input += ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Jpeg) + "|";
    }
} catch (Exception eee) {
    MessageBox.Show(eee.ToString());
}

【问题讨论】:

  • 哈哈它的措辞很糟糕,只是我复制某人的 Skype 个人资料并保存他们的照片并以某种方式“成为他们”,就像旧的 MSN 机器人一样>
  • 如果您(仅用于测试目的)将Thread.Sleep(2000); 放在SaveSkypeAvatarToDisk() 和对Image.FromFile() 的调用之间会发生什么?
  • 以管理员身份启动程序时会发生什么?
  • SaveSkypeAvatarToDisk 有什么作用?如果您使用您创建的路径而不是字符串怎么办?使用 (Image image = Image.FromFile(file))
  • 您可以尝试在目录和代码中使用小写字母。顺便说一句 - 哪一行触发了异常?

标签: c# image fromfile


【解决方案1】:

尝试使用 Application.DoEvents() (http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx),这应该会延迟下一行的执行,直到文件被创建。

【讨论】:

    猜你喜欢
    • 2021-01-06
    • 1970-01-01
    • 2018-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多