【发布时间】:2011-04-18 06:00:17
【问题描述】:
我正在阅读一个文本文件,其中包含我正在处理的 MVC 网站中使用 C# 的 SQL 插入语句。调试我正在使用的功能时工作正常并且插入发生。但是一旦我发布站点并在我的本地机器上运行它(使用 IIS 设置甚至使用 asp.net 4.0),它似乎就不起作用了。
if (Request.Files != null && Request.Files["txtImportFile"] != null)
{
//newFilePath = Server.MapPath("\\" + DateTime.Now.Ticks + Request.Files["txtImportFile"].FileName);
string[] temp_string = Request.Files["txtImportFile"].FileName.Split(new char[] { '\\' });
string temp_filename = temp_string[temp_string.Count() - 1];
//newFilePath = Server.MapPath("\\temp\\" + DateTime.Now.Ticks + Request.Files["txtImportFile"].FileName);
newFilePath = Server.MapPath("\\temp\\" + DateTime.Now.Ticks + temp_filename);
Request.Files["txtImportFile"].SaveAs(newFilePath);
StreamReader reader = new StreamReader(newFilePath);
string contents = reader.ReadToEnd();
reader.Close();
Models.WingsRemoteDbLibrary dbLib = new Models.WingsRemoteDbLibrary();
string update_message = dbLib.UpdateSlaveItemsTable(contents);
if (System.IO.File.Exists(newFilePath))
System.IO.File.Delete(newFilePath);
RandomPopupView(update_message);
}
我希望我的解释听起来没有含糊。我会尽力回答任何进一步的问题。谢谢。
【问题讨论】:
-
如果当前的答案没有帮助,我强烈建议您添加有关实际错误的更多详细信息...
标签: c# asp.net-mvc