我已經將我的asp.net web項目轉換爲Cloud Service。當我在我的本地機器上編譯它時,它工作正常。但是當我將它部署在Windows Azure上,並將其作爲* .cloudapp.net運行時,它會顯示以下錯誤。它不會上傳或下載任何文件。任何幫助將不勝感激。謝謝!(在'/'應用程序中的服務器錯誤。無法找到文件)在Windows Azure中的錯誤
錯誤:'/'應用程序中的服務器錯誤。
找不到文件'E:\ approot \ uploads \ 129517348374782571'。
描述:執行當前Web請求期間發生未處理的異常。請查看堆棧跟蹤以獲取有關該錯誤的更多信息以及源代碼的位置。
異常詳細信息:System.IO.FileNotFoundException:無法找到文件'E:\ approot \ uploads \ 129517348374782571'。
源錯誤:
在當前web請求的執行過程中生成未處理的異常。關於異常的來源和位置的信息可以使用下面的異常堆棧跟蹤來標識。
堆棧跟蹤:
[FileNotFoundException異常:找不到文件 'E:\爲approot \上傳\ 129517348374782571'。] System.IO .__ Error.WinIOError(的Int32的errorCode,字符串maybeFullPath)12892807 系統。 IO.FileInfo.get_Length()+12550108 C:\ Users \ canosum \ documents \ visual studio 2010 \ Projects \ EsraSon2 \ EsraSon2 \ CourseList.aspx.cs中的EsraSon2.CourseList.gvPaths_SelectedIndexChanged(Object sender,EventArgs e):78 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e,Boolean causesValidation,String validationGroup)+1203 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean i ncludeStagesAfterAsyncPoint)3691 `
上傳代碼:
string temp = DateTime.Now.ToFileTime().ToString();
FileUpload1.PostedFile.SaveAs(Server.MapPath("uploads") +"\\"+ temp);
BLLFileUpload m_helper = new BLLFileUpload();
DateTime date = DateTime.Now;
m_helper.InsertUploadFiletoDB(temp, FileUpload1.FileName, date, 1, Convert.ToInt32(gvSemesters.SelectedRow.Cells[7].Text));
下載代碼:
BLLFileUpload m_helper = new BLLFileUpload();
string tempname = m_helper.getFileRealName(gvPaths.SelectedRow.Cells[2].Text);
string fName = Server.MapPath("uploads")+ "\\" + tempname;
FileInfo fi = new FileInfo(fName);
long sz = fi.Length;
Response.ClearContent();
Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", gvPaths.SelectedRow.Cells[3].Text));
Response.AddHeader("Content-Length", sz.ToString("F0"));
Response.TransmitFile(fName);
Response.End();