November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Not sure if it's a best practice, but this works:
1)
Set up a virtual path in your web.config (use the VirtualPathNativeProvider if you have an existing file structure you want to hook up in your solution)
<add showInFileManager="true" virtualName="Photos" virtualPath="~/Photos/" bypassAccessCheck="true" physicalPath="C:\Inetpub\episerverfiles\Photos" name="SitePhotos" type="EPiServer.Web.Hosting.VirtualPathNativeProvider,EPiServer" />
Then, you need to add a <location path="Photos"> section for your new virtual path so that IIS6 can deal with the files.
2)
Now you're good to go, so in your code, you can now get your folder like:
VirtualPathNativeProvider vpnp = (VirtualPathNativeProvider)VirtualPathHandler.GetProvider("SitePhotos");
And e.g. return an image url like return vpnp.VirtualPathRoot + "/epiworld.jpg";
Not sure if this was what you were looking for, but you can read more about virtualpaths in the sdk.
--
Lars Øyvind Bodahl
www.epinova.no
Hi,
or like this:
UnifiedDirectory dir = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetDirectory(virtualPathasString) as UnifiedDirectory;
//Per
Great, thanks!
Then I'll just add an AppSettings variable so the name of the provider isn't hard coded.
/Patrik
Hi,
What is considered Best Practice when it comes to getting a CMS5 counterpart for the old /upload/ directory? I've been searching all day and can't really find any good examples of it. Preferably without having to hard code paths in to the code.
Mvh,
/Patrik