爲什麼我下載文件後無法刪除文件?下載後無法刪除文件
我得到這個錯誤:
file 'exfile.jpgg' because it is being used by another process.
這裏是我的代碼,
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();
在試圖刪除它之前,您是否正在對文件進行任何操作?如果是這樣,請發佈該代碼。 –