c# - Visual Studio 2010 working directory -
i'm developing c# asp.net web application. i'm done it, have little problem. want save xml files "users" folder within project, if don't psychically hard code path "c:......\users" in project wants save file in "c:\program files (x86)\common files\microsoft shared\devserver\10.0\users" folder, annoying problem because can't use hard coded directory on our web hosts server. also, have checkbox list populates the "downloadlibrary" folder in project, , suppose download files fold looking "c:\program files (x86)\common files\microsoft shared\devserver\10.0\" folder download though populating correct folder. i'm confused this, first time has ever happened me. can please me this, thing standing in way complete project.
you don't want use working directory @ all; want use directory relative web application located (which can retrieved httprequest.applicationpath.
httprequest request = httpcontext.current.request; // physical path web application string pathtoapp = request.mappath(request.applicationpath); string userspath = system.io.path.combine(pathtoapp, "users"); update
vincayc points out; asp.net development not strongest skill ;) above code equivalent of (much simpler) code:
string userspath = httprequest.current.request.mappath("~/users"); if code appears in code-behind of page, can cut httpcontext.current well, since page has request property.
Comments
Post a Comment