Could not get the file from VirtualPathVersioningProvider.OpenFile


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.




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

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

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

Try with:

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

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

Hope this helps.
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.