Esempio n. 1
0
        public static string ReplaceIncTag(string sContent, string sPath)
        {
            MatchCollection matchs = new Regex("<!--#include virtual=\"(.*?)\".*?-->", RegexOptions.Singleline).Matches(sContent);

            if (matchs.Count != 0)
            {
                string path     = string.Empty;
                string newValue = string.Empty;
                for (int i = 0; i < matchs.Count; i++)
                {
                    newValue = string.Empty;
                    path     = matchs[i].Groups[1].Value;
                    if (path.StartsWith("/"))
                    {
                        path = HttpContext.Current.Server.MapPath(path);
                    }
                    else if (path.StartsWith("../"))
                    {
                        path = sPath.TrimEnd(new char[] { '\\' }) + @"\..\" + path.Replace("/", @"\");
                    }
                    else
                    {
                        path = sPath.Substring(0, sPath.LastIndexOf(@"\") + 1) + path;
                    }
                    if (File.Exists(path))
                    {
                        newValue = ReplaceIncTag(CFile.Read(path), path);
                    }
                    sContent = sContent.Replace(matchs[i].Value, newValue);
                }
            }
            return(sContent);
        }
Esempio n. 2
0
        public static void Delete(string sPath)
        {
            string[] files = Directory.GetFiles(sPath);
            foreach (string str in files)
            {
                try
                {
                    CFile.Delete(str);
                }
                catch
                {
                }
            }
            string[] directories = Directory.GetDirectories(sPath);
            foreach (string str2 in directories)
            {
                try
                {
                    Delete(str2);
                }
                catch
                {
                }
            }
            FileInfo info = new FileInfo(sPath)
            {
                Attributes = FileAttributes.Normal
            };

            Directory.Delete(sPath);
        }