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
Try the GetPageDirectory method on your PageData object
http://sdk.episerver.com/library/cms6/html/M_EPiServer_Core_PageData_GetPageDirectory.htm