我正在尝试执行以下操作:
var path = Server.MapPath("File.js"));
// Create the file if it doesn't exist or if the application has been restarted
// and the file was created before the application restarted
if (!File.Exists(path) || ApplicationStartTime > File.GetLastWriteTimeUtc(path)) {
var script = "...";
using (var sw = File.CreateText(path)) {
sw.Write(script);
}
}
但是有时有时会抛出以下错误:
该进程无法访问文件“...\File.js”,因为它正被另一个进程使用
我在这里看过类似的问题,但我的似乎与其他问题略有不同。此外,在服务器负载过重之前我无法复制它,因此我希望在上传修复程序之前确保它是正确的。
如果有人能告诉我如何解决这个问题,我将不胜感激。
谢谢