我有一个后台工作程序,用于检查文件哈希值和大小,并与列表进行比较。我想在检查文件的时候这样做,如果它没有退出它会下载然后继续列表,它在以下代码中出错。
using (Stream streamLocal = new FileStream(sFilePathToWriteFileTo, FileMode.Create))
我只在某些文件上收到错误,错误The process cannot access the file because it is being used by another process.
当没有其他文件使用它时,或者除非它在检查时尝试下载它。
答案 0 :(得分:0)
听起来你并不关心这个错误。所以只需把它放在试块中
try
{
using (Stream streamLocal = new FileStream(sFilePathToWriteFileTo, FileMode.Create))
{
...
}
}
catch { }