我加載一個文件:c#ASP.NET如何刪除另一個進程「正在使用」的文件?
System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath);
現在我想保存圖片:
img.Save(SavePath);
這工作。除非FilePath == SavePath
,然後決定給我的錯誤:
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
於是,我就刪除該文件,打開後立即:
System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath);
File.Delete(FilePath);
,它給我的錯誤:
System.IO.IOException: The process cannot access the file 'filename.jpg' because it is being used by another process.
所以...... 我如何修改現有的文件,這就是「使用」時,其不被任何人使用?
此頁幫了不少忙。 – Justin808 2010-09-23 01:45:51
@ Justin808如果它幫助你應該投票。 – 2010-09-23 02:06:47
很高興我幫了忙。 – 2010-09-23 04:15:38