尝试下载文件时:进程无法访问该文件,因为它正被另一个进程使用

时间:2010-10-17 14:32:41

标签: asp.net

我正在尝试从服务器下载文件但我收到此错误:

该进程无法访问xxxx文件,因为该文件正被其他进程使用

这是我的代码:

    string fileName="DownLoadFiles";
    string filePath = hid_filepath.Value;
    FileInfo file = new FileInfo(filePath);      
    System.Net.WebClient wc = new System.Net.WebClient();
    wc.DownloadFile(new Uri(fileName, filePath);

敌人信息:文件未打开或未使用...

任何人都可以通过提供此错误的原因以及如何解决此错误来帮助我

1 个答案:

答案 0 :(得分:1)

 wc.DownloadFile(new Uri(fileName, filePath);

您的代码中存在错误,应该指定目标文件名:

 wc.DownloadFile(new Uri(fileName, filePath),"c:\file.tmp");