2015-04-17 73 views
-2

Exception Details: System.Web.HttpException: 'c:/users/agaabhis/documents/visual studio 2010/Projects/WebApplication4/WebApplication4/Files/' is a physical path, but a virtual path was expected.Asp.net使用從Excel C#文件上傳的SQL Server 08

源錯誤:

Line 23: Line 24: //Upload and save the file Line 25:
string excelPath = Server.MapPath("c://users/agaabhis/documents/visual studio 2010/Projects/WebApplication4/WebApplication4/Files/") + Path.GetFileName(FileUpload1.PostedFile.FileName); Line 26:
FileUpload1.SaveAs(excelPath); Line 27:

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

有一點信息會很有幫助,例如:你的源代碼。 –

回答

1

如果你讀了Server.MapPathon msdn的文檔,你會發現,你不能把它物理路徑(以驅動器爲根)。你需要給它相對於服務器的路徑。例如:

string excelPath = Server.MapPath("Files/") + ...; 
相關問題