【发布时间】:2013-09-15 10:34:44
【问题描述】:
我正在使用Visual Studio 2010 开发网站。我正在尝试将文件保存在路径中。它工作正常本地主机。
但相同的代码在 IIS 中不起作用。它显示以下错误
异常详细信息:System.IO.DirectoryNotFoundException:无法 找到路径“C:\Inetpub\wwwroot\Vendor\cn.jpg”的一部分。
找不到路径“C:\Users\shashank\Desktop\ab.csv”的一部分。
代码如下:
protected void btnImportFile_Click(object sender, EventArgs e)
{
sArReportText = File.ReadAllText(txtFilePath.Text.Trim());
// Set the report Properties to insert Report information
SetProperties();
}
【问题讨论】:
-
错误很清楚,目录或路径不存在。
-
检查'C:\Inetpub\wwwroot\Vendor\cn.jpg'目录是否在你的机器中。
-
您的应用程序池身份是否对该文件夹具有权限?
-
路径存在于我的系统上我已在服务器上托管应用程序并从那里访问它
-
因为它在服务器中搜索而不是在您的系统中。
标签: c# asp.net visual-studio-2010 filenotfoundexception