string folderPath = System.Configuration.ConfigurationManager.AppSettings["UploadPath"].ToString(); DirectoryInfo d = new DirectoryInfo(@MD.Path);//here I get D:\images FileInfo[] Files = ((d.GetFiles("*.jpg", SearchOption.AllDirectories)).Union(d.GetFiles("*.png", SearchOption.AllDirectories))).ToArray(); //here i get all images string str = ""; ImageBL objBL = new ImageBL(); foreach (FileInfo file in Files) { var InputFileName = Path.GetFileName(file.Name); string path = Server.MapPath("~/" + folderPath + "/"); var RPaths = Server.MapPath("~/" + folderPath + "//" + "Images" + "//" + MD.YrID + "//" + MD.RPath); var ServerSavePath = Server.MapPath("~/" + folderPath + "//" + "Images" + "//" + MD.YrID + "//" + MD.RPath + "//" + InputFileName); <pre> if (!System.IO.Directory.Exists(RPaths)) { System.IO.Directory.CreateDirectory(RPaths); } if (System.IO.File.Exists(ServerSavePath)) { ServerSavePath.Replace(ServerSavePath, System.DateTime.Now.ToLocalTime() + "" + ServerSavePath); } else { file.CopyTo(ServerSavePath); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)