{ "aspx", "ascx", "master", "ashx", "cs", "xml", "css", "js" };
                if (!allowFileTypes.Contains(fileType))
                {
                    return;
                }
                // 读取文件内容
                string content = File.ReadAllText(Server.MapPath(file));
                desc.Text = "" + HttpUtility.HtmlEncode(content) + "
"; // linenums
            }
        }
        private bool UnderRootPath(string fileName)
        {
            string filePath = Server.MapPath(fileName);
            string rootPath = Server.MapPath("~/");
            return filePath.StartsWith(rootPath);
        }
        private string GetBasePath(string fileName)
        {
            string filePath = Server.MapPath(fileName);
            string rootPath = Server.MapPath("~/");
            string basePath = filePath.Substring(rootPath.Length);
            int slashIndex = basePath.IndexOf("\\");
            if (slashIndex >= 0)
            {
                basePath = basePath.Substring(0, slashIndex);
            }
            return basePath;
        }
        private string GetFileType(string fileName)
        {
            string fileType = String.Empty;
            int lastDotIndex = fileName.ToLower().LastIndexOf(".");
            if (lastDotIndex >= 0)
            {
                fileType = fileName.Substring(lastDotIndex + 1);
            }
            return fileType;
        }
    }
}