title: Getting server path to image in C#
body: <p>I'm using EPPlus (props to the devs for an awesome library) to make an Excel doc that will be downloaded in the browser. In the code that generates the Excel doc, I have a few lines that are meant to include an image file in the Excel doc.</p>
  
  <pre><code>Image logoImg = Image.FromFile(Server.MapPath("~/Images/bill_logo.png"));
  var logo = ws.Drawings.AddPicture("Logo", logoImg);
  </code></pre>
  
  <p>When I run the project locally on my machine, the image shows up as expected. However, when I deploy to our test environment in Azure, I get the following error:</p>
  
  <pre><code>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.&lt;&gt;c__DisplayClass42.&lt;BeginInvokeSynchronousActionMethod&gt;b__41()
  at System.Web.Mvc.Async.AsyncResultWrapper.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;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.&lt;&gt;c__DisplayClass37.&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33()
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49()
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass37.&lt;BeginInvokeActionMethodWithFilters&gt;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.&lt;&gt;c__DisplayClass25.&lt;&gt;c__DisplayClass2a.&lt;BeginInvokeAction&gt;b__20()
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass25.&lt;BeginInvokeAction&gt;b__22(IAsyncResult asyncResult)
  </code></pre>
  
  <p>What is the best way to reference this image file so that it works across environments?</p>