2
我試圖創建和使用下面的代碼如何建立txt文件,並把它寫C#asp.net
System.IO.Directory.CreateDirectory(Server.MapPath("~\\count"));
using (System.IO.FileStream fs = new System.IO.FileStream("~/count/count.txt", System.IO.FileMode.Create))
using (System.IO.StreamWriter sw = new System.IO.StreamWriter("~/count/count.txt"))
{
sw.Write("101");
}
string _count = System.IO.File.ReadAllText("~/count/count.txt");
Application["NoOfVisitors"] = _count;
寫在C#應用程序的文本文件,但我得到一個錯誤:
The process cannot access the file 'path' because it is being used by another process.
我的錯誤是什麼?
我需要重新啓動visual studio或系統? – 2014-10-04 07:37:56
重新啓動你的電腦肯定會修復它(除非它是你的應用程序的早期部分鎖定它),但否則它取決於它鎖定的是什麼。 – 2014-10-04 07:51:22
我嘗試了兩個選項,但仍面臨相同的問題.... – 2014-10-04 08:16:30