首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请教:System.IO 文件“d:\test.ascx”正由另一进程使用,因此该进程无法访问该文件

2012-01-18 
请问:System.IO 文件“d:\test.ascx”正由另一进程使用,因此该进程无法访问该文件。stringstrPathd:\\test.

请问: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);
// ...

热点排行