Beispiel #1
0
        private string AddImageToFolder(HttpPostedFileBase picture, string imgPath)
        {
            var imgFileName = DateTime.Now.ToFileTimeUtc() + "." + HtmlHelpers.GetExt(picture.FileName);

            if (System.IO.File.Exists(Server.MapPath(imgPath + "/" + imgFileName)))
            {
                System.IO.File.Delete(Server.MapPath(imgPath + "/" + imgFileName));
            }
            picture.SaveAs(Server.MapPath(Path.Combine(imgPath, imgFileName)));
            string item = imgPath + "/" + imgFileName;

            return(item);
        }