文件写入操作后"IOException: The process cannot access the file ..... because it is being used by another p



两个不同的代码给出相同的结果。文件上传或写入成功发生到文件夹,但是当上传或写入具有相同目标的另一个文件时,我得到了ioexception。另一个过程是使用它。我什至无法使用资源管理器删除文件。IIS + Asp.net 核心。因此,第一次上传会产生锁定。

代码:

1

using (var writer = System.IO.File.CreateText(webRootPath+"/uploads/"+filename)){
writer.WriteLine(content);
}

阿拉伯数字

using (var stream = new FileStream(webRootPath+"/uploads/"+formFile.FileName, FileMode.Create)){
await formFile.CopyToAsync(stream);
}

问题已解决。另一个过程是在我的代码中使用文件。谢谢迪米特里

相关内容

最新更新