Try our conversational search powered by Generative AI!

Getting directory from PageFiles folder of EPiServer

Vote:
 

I'm having some thoughts about how the EPiServer PageFiles system work. When I get a global file it's simple to get the correct directory, I just write:

var dir = VirtualPathHandler.Instance.GetDirectory("~/Global/myfolder/", true)

But when I want to get files from the PageFiles folder it gets tricky for me. The path in the EPi backoffice upload says it is PageFiles/myfolder, but this doesn't return any folders

var dir = VirtualPathHandler.Instance.GetDirectory("~/PageFiles/myfolder/", true)

Now I see that files are saved different for each page, one page has the path /PageFiles/361/myfolder/ and another page has the path /PageFiles/65/myfolder/. All I want to do is be able to write

var dir = VirtualPathHandler.Instance.GetDirectory("~/PageFiles/myfolder/", true)

but to get any folder I have to write (for instance)

var dir = VirtualPathHandler.Instance.GetDirectory("~/PageFiles/65/myfolder/", true)

What is the correct way to get a PageFiles folder so I can access all files in it?

BTW, this is EPiServer 6.0

#199873
Dec 17, 2018 6:34
* 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.