Beispiel #1
0
        public static string ReadStaticFile(string virtualPath)
        {
            if (FileRepositoryManager.FileExists(virtualPath))
            {
                ActionResult        result       = FileRepositoryManager.GetFile(virtualPath);
                StaticContentResult staticResult = result as StaticContentResult;

                using (MemoryStream ms = new MemoryStream(staticResult.Uncompressed))
                    using (StreamReader reader = new StreamReader(ms))
                        return(reader.ReadToEnd());
            }
            else
            {
                if (virtualPath.StartsWith("~"))
                {
                    virtualPath = VirtualPathUtility.ToAbsolute(virtualPath);
                }

                using (Stream str = VirtualPathProvider.OpenFile(virtualPath))
                    using (StreamReader reader = new StreamReader(str))
                        return(reader.ReadToEnd());
            }
        }
Beispiel #2
0
 public ActionResult GetFile(string file)
 {
     return(FileRepositoryManager.GetFile("~/" + file));
 }