【问题标题】:Asp.net with c# file upload from excel using sql server 08 [closed]使用 sql server 08 从 excel 上传 c# 文件的 Asp.net [关闭]
【发布时间】:2015-06-23 21:24:03
【问题描述】:

异常详细信息:System.Web.HttpException: 'c:/users/agaabhis/documents/visual studio 2010/Projects/WebApplication4/WebApplication4/Files/'是物理的 路径,但需要一个虚拟路径。

来源错误:

Line 23: Line 24: //上传并保存文件 Line 25:
string excelPath = Server.MapPath("c://users/agaabhis/documents/visual 工作室 2010/Projects/WebApplication4/WebApplication4/Files/") + Path.GetFileName(FileUpload1.PostedFile.FileName);第 26 行:
FileUpload1.SaveAs(excelPath);第 27 行:

 Source File:  c:\users\agaabhis\documents\visual studio 2010\Projects\WebApplication4\WebApplication4\Default.aspx.cs    Line:  25 

【问题讨论】:

  • 更多信息会很有帮助,例如你的源代码。

标签: sql asp.net excel sql-server-2008 exception


【解决方案1】:

如果您阅读Server.MapPath on msdn 的文档,您会发现您无法将物理路径(以驱动器作为根目录)传递给它。您需要为其提供相对于服务器的路径。例如:

string excelPath = Server.MapPath("Files/") + ...;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-04
    • 1970-01-01
    • 1970-01-01
    • 2014-05-10
    • 2011-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多