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
Post a Comment