Try our conversational search powered by Generative AI!

Need physical path to VPP root

Vote:
 

Hi!

I have a situation where I would like to refer to the physical path of the VPP directory (ex. c:/sites/site1/vpp). I could of course hard code the directory but I really would like to generate this directory path dynamically from code behind. I've look around but I haven't found a way to reference this physical path. I'm not really interested in c:/sites/site1/vpp/global files or c:/sites/site1/vpp/pagefiles but the root of the whole vpp. Anyone know of this is possible?

#89718
Aug 22, 2014 16:39
Vote:
 

Hi

First, there is no common root for virtual path providers. That is it is no requirement that all must reside in same directory (even if that is the typical scenario) for example you could have one mapped to a local drive as "c:\vpps\global" while another is on a file share like "\\fileshare\vpps\shared". 

What you can do is get all vpps in the system by accessing VirtualPathHandler.Instance.VirtualPathProviders (this give you a dictionary where the provider is the key). Note that this contain all registered virtual path providers, some of them might not be backed by a filesystem (e.g. there are database backed providers).

So in your case I guess you are interested of instances of VirtualPathVersioningProvider (and potentially VirtualPathNativeProvider). So then you should get all providers of those types (and cast them). Then you can access the physical root as property "PhysicalBasePath" (for versioning provider) or "LocalPath" (for native provider).

#89719
Aug 22, 2014 16:55
Vote:
 

Okey, thank you Johan. I decided to solve my issue by adding the root path to a variable in web.config.

#89918
Aug 28, 2014 13:27
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.