Try our conversational search powered by Generative AI!

Could not get the file from VirtualPathVersioningProvider.OpenFile

Vote:
 

I pass the the virtual path, but got exception of null refrence. I can get the extention by using  VirtualPathUtility.GetExtension(p). I need to get the file size.

 

eg.

 

            string p=filepath.ToString();
                string size=string.Empty;
                string extentionIcon=string.Empty;

                System.IO.Stream file = VirtualPathMappedProvider.OpenFile(p);
                if(file!=null)
                    size = GetFileSizeString(file.Length);


                extentionIcon = GetFileIcon(VirtualPathUtility.GetExtension(p));
#33957
Oct 22, 2009 17:52
Vote:
 

Try with:

var file = HostingEnvironment.VirtualPathProvider.GetFile(p) as UnifiedFile;

if (file != null)
{
    size = file.Length;
}

Hope this helps.
#33980
Oct 23, 2009 9:35
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.