我有一个使用 IIS 上传的 Web 应用程序。我希望使用该应用程序的用户能够选择位于他们(用户)计算机上的文件并读取其内容。
代码是:
TextReader trs = new StreamReader(faFile.Value);
DataAccessLayer.clearFA();
string line = trs.ReadLine();
// Read all unneeded data
while (line != "** Start Data **")
{
line = trs.ReadLine();
}
line = trs.ReadLine();
while (line != null)
{
string[] words = line.Split('*');
// There is no message
if (words[4] == "")
{
DataAccessLayer.insertIntoFA(Int32.Parse(words[1]), words[3].Replace("'", ""));
}
else
{
DataAccessLayer.insertIntoFA(Int32.Parse(words[1]), words[4].Replace("'", ""));
}
line = trs.ReadLine();
}
}
当我从我的电脑上运行它时,它可以工作。但是当我尝试从 IIS 运行它时,它给了我以下错误:
Could not find a part of the path 'C:\Documents and Settings\myUser\Desktop\file.txt'.
我了解应用程序无法从用户 pc 读取文件。知道如何使它工作吗?
谢谢!
格雷格