【发布时间】:2009-02-04 16:48:01
【问题描述】:
我正在处理的项目的一个要求是根据特定标准将文件导出到网络共享。当我在 Visual Studio 中运行代码时,它工作得很好,但是当我部署它时,将启动保存文件的操作以失败告终。用户看到警报:
Could not find file '<full filename...>'.
在 web.config 中,我将 impersonate 设置为 true,并且用户有权写入相关网络共享。
这是写入文件的代码:
using (System.IO.FileStream fs = new System.IO.FileStream(fullpath, System.IO.FileMode.Create))
{
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(fs))
{
sw.WriteLine(RouteMeter.HeaderString);
foreach (RouteMeter meter in rm)
{
sw.WriteLine(meter);
}
}
}
【问题讨论】: