예제 #1
0
        private string SaveYuanFile(Match m)
        {
            string text  = m.Value;
            string text2 = text.Substring(5);

            text2 = text2.Substring(0, text2.IndexOf("\""));
            Regex  regex = new Regex("^http://*");
            string result;

            if (regex.Match(text2).Success)
            {
                text = text.Substring(5);
                text = text.Substring(0, text.IndexOf("\""));
                string str      = ConfigurationManager.AppSettings["yuanimg"].ToString();
                string text3    = text;
                string str2     = text3.Substring(text3.LastIndexOf("."));
                string fileName = FileOperate.GetFileName();
                string text4    = str + fileName + str2;
                if (System.IO.File.Exists(System.Web.HttpContext.Current.Request.MapPath(text4)))
                {
                    System.IO.File.Delete(System.Web.HttpContext.Current.Request.MapPath(text4));
                }
                this.GetHttpFile(text, System.Web.HttpContext.Current.Request.MapPath(text4));
                result = "src=\"/" + text4.Replace("~/", "") + "\"";
            }
            else
            {
                result = text;
            }
            return(result);
        }
예제 #2
0
        public static string GetRemotUrl(string url, int Type)
        {
            string text   = url.Trim();
            string result = string.Empty;
            string text2  = string.Empty;

            try
            {
                HttpWebRequest       httpWebRequest  = (HttpWebRequest)WebRequest.Create(text);
                HttpWebResponse      httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                string               contentEncoding = httpWebResponse.ContentEncoding;
                System.IO.Stream     responseStream  = httpWebResponse.GetResponseStream();
                System.Text.Encoding encoding        = System.Text.Encoding.GetEncoding(FileOperate.GetChartset(text));
                if (contentEncoding.ToLower() == "gzip")
                {
                    GZipStream stream = new GZipStream(responseStream, CompressionMode.Decompress);
                    using (System.IO.StreamReader streamReader = new System.IO.StreamReader(stream, encoding))
                    {
                        text2 = streamReader.ReadToEnd();
                        goto IL_AA;
                    }
                }
                using (System.IO.StreamReader streamReader2 = new System.IO.StreamReader(responseStream, encoding))
                {
                    text2 = streamReader2.ReadToEnd();
                }
IL_AA:
                switch (Type)
                {
                case 1:
                    result = text2;
                    break;

                case 2:
                    result = FileOperate.wipeScript(text2);
                    break;

                case 3:
                    result = FileOperate.ClearHTML(text2);
                    break;

                case 4:
                    result = FileOperate.getImages(text, text2);
                    break;

                case 5:
                    result = FileOperate.getLink(text, text2);
                    break;
                }
            }
            catch
            {
                result = "Error";
            }
            return(result);
        }
예제 #3
0
 private static System.Collections.Hashtable getAllFies(string filesdirectorypath, out int dirnamelength)
 {
     System.Collections.Hashtable hashtable     = new System.Collections.Hashtable();
     System.IO.DirectoryInfo      directoryInfo = new System.IO.DirectoryInfo(filesdirectorypath);
     if (!directoryInfo.Exists)
     {
         throw new System.IO.FileNotFoundException("目录:" + directoryInfo.FullName + "没有找到!");
     }
     dirnamelength = directoryInfo.Name.Length;
     FileOperate.getAllDirFiles(directoryInfo, hashtable);
     FileOperate.getAllDirsFiles(directoryInfo.GetDirectories(), hashtable);
     return(hashtable);
 }
예제 #4
0
 private static void getAllDirsFiles(System.IO.DirectoryInfo[] dirs, System.Collections.Hashtable filesList)
 {
     for (int i = 0; i < dirs.Length; i++)
     {
         System.IO.DirectoryInfo directoryInfo = dirs[i];
         System.IO.FileInfo[]    files         = directoryInfo.GetFiles("*.*");
         for (int j = 0; j < files.Length; j++)
         {
             System.IO.FileInfo fileInfo = files[j];
             filesList.Add(fileInfo.FullName, fileInfo.LastWriteTime);
         }
         FileOperate.getAllDirsFiles(directoryInfo.GetDirectories(), filesList);
     }
 }
예제 #5
0
        public static string UpLoadFile(System.Web.UI.WebControls.FileUpload fileupload, string Folders)
        {
            string fileName = fileupload.PostedFile.FileName;

            if (fileName == null || fileName.Equals(""))
            {
                return("");
            }
            string str       = fileName.Substring(fileName.LastIndexOf("."));
            string fileName2 = FileOperate.GetFileName();
            string text      = Folders + fileName2 + str;
            string text2     = System.Web.HttpContext.Current.Server.MapPath(text);

            if (System.IO.File.Exists(text2))
            {
                System.IO.File.Delete(text2);
            }
            fileupload.PostedFile.SaveAs(text2);
            return(text);
        }
예제 #6
0
        private static string GetChartset(string url)
        {
            string hTML  = FileOperate.getHTML(url);
            Regex  regex = new Regex("charset\\b\\s*=\\s*(?<charset>[^\"]*)");
            string text;

            if (regex.IsMatch(hTML))
            {
                text = regex.Match(hTML).Groups["charset"].Value;
            }
            else
            {
                text = System.Text.Encoding.Default.EncodingName;
            }
            if (text.ToLower().Contains("gb2312"))
            {
                text = "gb2312";
            }
            if (text.ToLower().Contains("utf-8"))
            {
                text = "utf-8";
            }
            return(text);
        }
예제 #7
0
        public static System.Collections.ArrayList ReadKeys(string sectionName, string path)
        {
            byte[] array = new byte[5120];
            int    privateProfileStringA = FileOperate.GetPrivateProfileStringA(sectionName, null, "", array, array.GetUpperBound(0), path);

            System.Collections.ArrayList arrayList = new System.Collections.ArrayList();
            if (privateProfileStringA > 0)
            {
                int num = 0;
                for (int i = 0; i < privateProfileStringA; i++)
                {
                    if (array[i] == 0)
                    {
                        string text = System.Text.Encoding.Default.GetString(array, num, i - num).Trim();
                        num = i + 1;
                        if (text != "")
                        {
                            arrayList.Add(text);
                        }
                    }
                }
            }
            return(arrayList);
        }
예제 #8
0
 public static byte[] IniReadValues(string section, string key, string path)
 {
     byte[] array = new byte[255];
     FileOperate.GetPrivateProfileString(section, key, "", array, 255, path);
     return(array);
 }
예제 #9
0
 public static string IniReadValue(string section, string key, string path)
 {
     System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(255);
     FileOperate.GetPrivateProfileString(section, key, "", stringBuilder, 255, path);
     return(stringBuilder.ToString());
 }
예제 #10
0
 public static void IniWriteValue(string section, string key, string iValue, string path)
 {
     FileOperate.WritePrivateProfileString(section, key, iValue, path);
 }
예제 #11
0
 public static void SetXmlValue(string Target, string attributes, string TargetValue, string xmlPath)
 {
     FileOperate.SetXmlTargetValue(Target, attributes, TargetValue, xmlPath);
 }