Recently, because of work needs, WPF has made a helper gadget, such as
In order to get the physical path of the site, I analyzed the variables obtained through Servermanager, but also through Baidu search a lot, but still no way to find.
Later use of Bing, found in foreign sites, do not know is not the right way to open, so experienced such twists and turns, the following I get the method of physical path to write down for your reference, hoping to help posterity.
1 Private stringGetwebsitephysicalpath (site site)2 {4 varApplicationroot = site. Applications.where (A = A.path = ="/"). Single ();5 varVirtualRoot = ApplicationRoot.VirtualDirectories.Where (v = V.path = ="/"). Single ();6 stringRET =Virtualroot.physicalpath;7 string[] strlist = ret. Split ('%'). Where (t = = t! ="%"). ToArray ();8RET ="";9 for(inti =0; i < strlist.length; i++)Ten { One stringspath =environment.getenvironmentvariable (Strlist[i]. ToLower ()); A if(string. IsNullOrEmpty (spath)) - { -RET + =Strlist[i]; the } - Else - { -RET + =spath; + } - } + returnret; A}
Resources:
[1]https://stackoverflow.com/questions/5431703
. NET using Servermanager to get the physical path of a Web site