Example #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);
        }
Example #2
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);
        }