PropertyDocumentUrl how do I retrive the VPP path


scenario trying to allow the user to download and uploaded file from the VPP store:

using the page type builder I;ve declared the following property:

        [PageTypeProperty(Searchable = false, Type = typeof(PropertyDocumentUrl), EditCaption = "File", HelpText = "File", Tab = typeof(InformationTab), SortOrder = 2)]
        public virtual string FileSrc { get; set; }

now when I retrieve this value back it returns the relative path e.g.

var filePath = "/BigAmbition/Images/Competition/Teacher%20Support%20Project%20Management_final.pdf"

Trying to map this to the physical path using the following code:

var vppFilePath = HostingEnvironment.VirtualPathProvider.GetFile(filePath) as UnifiedFile;

when I look in table tblProperty the string field has the following value: ~/link/58ec8df05b0a4d52a6e6d86cde2c2141.pdf, when I hardcode this in the filePath the vpp path returns a unifiedfile back, question i have is how do I retrieve this value?



Nov 25, 2010 18:34

vppFilePath.VirtualPath is the file location., the /link/58.... stuff is the guid path to the file, and will always work regardless if you move the file.


The pysical path to the file is vppFilePath.LocalPath



Nov 25, 2010 21:05

Sorry didn't make it clear in the example above, vppFilePath returns null when the argument is passed as:

CurrentPage.FileSrc //holds the value /BigAmbition/Images/Competition/Teacher%20Support%20Project%20Management_final.pdf

HostingEnvironment.VirtualPathProvider.GetFile("/BigAmbition/Images/Competition/Teacher%20Support%20Project%20Management_final.pdf") as UnifiedFile;

When I access CurrentPage.FileSrc this returns the friendlyUrl I want to know how to retrieve the vpp path.

Nov 26, 2010 10:17
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.