protected void Button2_Click(object sender, EventArgs e) { DirectoryInfo di = new DirectoryInfo(@"D:\ICB Unit Fund Conversion Data\nrb2\signature\BD0166INRB27"); FileInfo[] finfos = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly); foreach (FileInfo fi in finfos) { string newFileName = ""; string fileName = fi.Name.ToString(); string[] spliteFileName = fileName.Split('.'); string fileBO = spliteFileName[0].Substring(0, 16); // string fileBO = spliteFileName[0].ToString(); string fileNameReg = opendMFDAO.getRegNoByFolio(fileBO.ToString()).ToString(); if (fileNameReg != "0") { newFileName = @"\\194.25.1.202\inv_Signature\INRB2\INRB2_AMC_01_" + fileNameReg.ToString() + ".jpg"; } else { newFileName = @"\\194.25.1.202\inv_Signature\INRB2\INRB2_AMC_01_Not_Found_" + spliteFileName[0].ToString() + ".jpg"; } File.Copy(fi.DirectoryName.ToString() + "\\" + fi.ToString(), newFileName); // File.Move(fi.DirectoryName.ToString() + "\\" + fi.ToString(), newFileName); //string newFileLocation = System.IO.Path.Combine(@"\\Deco-07\pension_unit_vb\Images\inv_Signature\IAMCL_NEW\", newFileName); //.Write(newFileLocation); } }