c# - Map path to App_Data with HttpContext.Current.Server.MapPath() -


i writing small wpf application use word templates , merge them data. issue trying avoid using absolute path app_data folder in visual studio c# project obvious reasons. i'm trying map path app_data folder can use template there. giving me following error:

system.nullreferenceexception occurred: object reference not set instance of object. system.web.httpcontext.current.get returned null. 

here code:

string path = httpcontext.current.server.mappath("/app_data"); path = path + "/acknowledgement_letter.dotx"; 

you should use ~ before path

string path = httpcontext.current.server.mappath("~/app_data");


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -