问题描述
这是我的基本代码:
#region privateMethods
private bool SaveImageFile(string absolutePathFile,byte[] file,ImageFormat format)
{
try
{
string directoryPath = Path.GetDirectoryName(absolutePathFile);
if (!Directory.Exists(directoryPath)) Directory.CreateDirectory(directoryPath);
if (File.Exists(absolutePathFile)) File.Delete(absolutePathFile);
using (MemoryStream ms = new MemoryStream(file))
using (var bmp = Image.FromStream(ms))
bmp.Save(absolutePathFile,format);
return true;
}
catch (ArgumentException argEx)
{
EventLogger.WriteLog("UploadImageFile: This file it isn't an image " + argEx.Message,System.Diagnostics.EventLogEntryType.Error);
}
catch (Exception ex)
{
EventLogger.WriteLog("UploadImageFile: " + ex.Message + " " + ex.StackTrace + "PathFile: " + absolutePathFile,System.Diagnostics.EventLogEntryType.Error);
}
return false;
}
这看起来很基础。哪个可能是原因?或者我怎样才能更好地进行调查?
这似乎并不总是发生,而是“有时”。这真的很奇怪并且在控制之下,发生的随机性......
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)