读书人

请教:System.IO 文件“d:\test.ascx”

发布时间: 2012-01-18 00:23:26 作者: rapoo

请问:System.IO 文件“d:\test.ascx”正由另一进程使用,因此该进程无法访问该文件。
string strPath = "d:\\test.ascx ";
File.Create(strPath);
StreamWriter sw = new StreamWriter(strPath, false);
string sContent = hiContent.Value;
sw.Write(sContent);
sw.Close();

错误
文件“d:\test.ascx”正由另一进程使用,因此该进程无法访问该文件。

[解决办法]
string strPath = "d:\\test.ascx ";File.Create(strPath);==> 这两句不需要.
[解决办法]
// OR
string strPath = "d:\\test.ascx ";
FileStream stream = File.Create(strPath);
StreamWriter sw = new StreamWriter(stream);
// ...

读书人网 >asp.net

热点推荐