브라우저에서 다운로드 할 Excel 문서를 만들기 위해 EPPlus (멋진 라이브러리의 경우 devs에 소품)를 사용하고 있습니다. Excel 문서를 생성하는 코드에서 Excel 문서에 이미지 파일을 포함 할 몇 줄의 행이 있습니다.C#으로 서버 경로 가져 오기
Image logoImg = Image.FromFile(Server.MapPath("~/Images/bill_logo.png"));
var logo = ws.Drawings.AddPicture("Logo", logoImg);
내 시스템에서 로컬로 프로젝트를 실행하면 이미지가 예상대로 표시됩니다. 그러나, 나는 푸른 우리의 테스트 환경에 배포 할 때, 다음과 같은 에러가 발생합니다
System.IO.FileNotFoundException: C:\DWASFiles\Sites\sitename\VirtualDirectory0\site\wwwroot\Images\bill_logo.png
at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
at System.Drawing.Image.FromFile(String filename)
at emergePortal.Web.Controllers.BillingController.buildWorksheet(ExcelWorksheet ws, String sheetName, IEnumerable`1 lineItems) in c:\a\src\emergePortal\emergePortal.Web\Controllers\BillingController.cs:line 202
at emergePortal.Web.Controllers.BillingController.getBill(Int32 billMonth, Int32 billYear) in c:\a\src\emergePortal\emergePortal.Web\Controllers\BillingController.cs:line 106
at lambda_method(Closure , ControllerBase , Object[])
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult)
이 환경에서 작동하도록이 이미지 파일을 참조 할 수있는 가장 좋은 방법은 무엇입니까?
설정 읽고 당신의 이미지가 내가 잘못 될 수있다 –
폴더에 쓰기 참조 내가 당신의 문제에 대한이 코드를 사용 생각 처음은 아니지만 Azure에서 권한을 편집 할 수 있다고 생각하지 않습니다. – Trevor
티켓을 Azure로 보낼 수 있습니다. http://www.windowsazure.com/en-us/support/options/ –