![](/img/trans.png)
[英]Can't delete the file after displaying on printpreviewcontroller
[英]Can't delete file after downloading
下載文件后為什么不能刪除文件?
我收到此錯誤:
文件'exfile.jpgg',因為它正在被另一個進程使用。
這是我的代碼,
string file_name = "pic.jpg"
WebClient client = new WebClient();
client.DownloadFile("http://picture.com/pic.jpg", file_name);
client.Dispose();
client = null;
pictureBox1.Image = Image.FromFile(File_Name);
pictureBox1.Image = null;
FileInfo MyFile = new FileInfo(File_Name);
MyFile.Delete();
您需要處理Image
對象。
該文件將保持鎖定,直到處理完映像為止。
您可以使用ProcessExplorer來檢查誰對此文件尚未公開。
聽起來您需要先關閉WebClient,因為它將鎖定。 也許使用
WebClient.Close() or WebClient.Dispose()
希望這能給您提示並為您提供幫助,最好的問候,湯姆。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.