. NET using Servermanager to get the physical path of a Web site

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.