Exemplo n.º 1
0
        private string SaveYuanFile(System.Text.RegularExpressions.Match m)
        {
            string str   = "";
            string value = m.Value;
            string str1  = "";

            str1 = value.Substring(5);
            str1 = str1.Substring(0, str1.IndexOf("\""));
            if (!(new Regex("^http://*")).Match(str1).Success)
            {
                str = value;
            }
            else
            {
                value = value.Substring(5);
                value = value.Substring(0, value.IndexOf("\""));
                string str2 = ConfigurationManager.AppSettings["yuanimg"].ToString();
                string str3 = value;
                string str4 = str3.Substring(str3.LastIndexOf("."));
                string str5 = string.Concat(str2, FileOperate.GetFileName(), str4);
                if (File.Exists(HttpContext.Current.Request.MapPath(str5)))
                {
                    File.Delete(HttpContext.Current.Request.MapPath(str5));
                }
                this.GetHttpFile(value, HttpContext.Current.Request.MapPath(str5));
                str = string.Concat("src=\"/", str5.Replace("~/", ""), "\"");
            }
            return(str);
        }
Exemplo n.º 2
0
        public static string UpLoadFile(FileUpload fileupload, string Folders)
        {
            string fileName = fileupload.PostedFile.FileName;

            if (fileName == null || fileName.Equals(""))
            {
                return("");
            }
            string str  = fileName.Substring(fileName.LastIndexOf("."));
            string str1 = string.Concat(Folders, FileOperate.GetFileName(), str);
            string str2 = HttpContext.Current.Server.MapPath(str1);

            if (File.Exists(str2))
            {
                File.Delete(str2);
            }
            fileupload.PostedFile.SaveAs(str2);
            return(str1);
        }