Last post Jun 16, 2017 02:48 AM by Cathy Zou
Jun 15, 2017 12:23 PM|RageRiot|LINK
Is it possible to save a file behind the root of the domain?
For example, our domain is hosting points to:
And I'd like to save at:
string mypath = "//myfolder//" + fileName;
Jun 15, 2017 12:31 PM|PatriceSc|LINK
Yes, just use whatever physical path you want. The purpose of Server.MapPath is to match a vritual path (ie a url) on your site to a physical location on the server hard drive so if you want to save something at some location you already have a physical
location and you shouldn't use Server.MapPath...
For example it could be :
string mypath = @"d:\fileuploads\"+ fileName; // Or it could be a network share etc...
Just make sure the account Under which your app runs is allowed to write at this location...
Jun 16, 2017 02:48 AM|Cathy Zou|LINK
Using the following code, you will get the root directory of the current application
string path ==Server.MapPath("~")
string path =(HttpRuntime.AppDomainAppPath
as a path on the disk. E.g.
C:\Users\v-guzou\documents\visual studio 2015\Projects\SolutionOne\CaseTest\
Then you could save file behind domain root as the following :