We are using the VirtualPathProvider stuff to get a files uploaded by the editor of a site, using File Manager.
We will have a folder per site in out Enterprise installation og EPiServer.
What I would like to be able to do is auto create the folder if it is not there. I have some code to do this but it seems a little flaky and I doubt the right permissions will be set.
I am using this code
// Rewrite path to the VPP folder for the site string siteId = Settings.Instance.Parent.SiteId;
EPiServer.Web.Hosting.VirtualPathVersioningProvider siteSpecificVpp = new VirtualPathVersioningProvider(siteId, config);
// Register provider then update mappings so that it will appear in the File Manager correctly GenericHostingEnvironment.RegisterVirtualPathProvider(siteSpecificVpp);
VirtualPathUnifiedProvider siteSpecific = siteSpecificVpp as VirtualPathUnifiedProvider; if (siteSpecific != null) { string absolutePath = VirtualPathUtility.AppendTrailingSlash(VirtualPathUtilityEx.ToAbsolute(config["virtualPath"]));
if (VirtualPathHandler.Instance.NameToVirtualPathMapping.ContainsKey(config["name"]) == true) { VirtualPathHandler.Instance.NameToVirtualPathMapping[config["name"]] = absolutePath; } else { KeyValuePair nameToPathMapping = new KeyValuePair(config["name"], absolutePath); VirtualPathHandler.Instance.NameToVirtualPathMapping.Add(nameToPathMapping); }
if (VirtualPathHandler.Instance.VirtualPathToNameMapping.ContainsKey(absolutePath) == true) { VirtualPathHandler.Instance.VirtualPathToNameMapping[absolutePath] = config["virtualName"]; } else { KeyValuePair pathToNameMapping = new KeyValuePair(absolutePath, config["virtualName"]); VirtualPathHandler.Instance.VirtualPathToNameMapping.Add(pathToNameMapping); } }
We are using the VirtualPathProvider stuff to get a files uploaded by the editor of a site, using File Manager.
We will have a folder per site in out Enterprise installation og EPiServer.
What I would like to be able to do is auto create the folder if it is not there. I have some code to do this but it seems a little flaky and I doubt the right permissions will be set.
I am using this code
Does anyone have a better idea?
Thanks
Pat Long