Move Files from one folder to another in ASP.NET
You can move files from one folder to another by using the below codeusing System.IO;
DirectoryInfo dirInfo1 = new DirectoryInfo("D:Folder1");
DirectoryInfo dirInfo2 = new DirectoryInfo("D:Folder2");
FileInfo[] Folder1Files = dirInfo1.GetFiles();
if (Folder1Files.Length > 0)
{
foreach (FileInfo aFile in Folder1Files)
{
if (File.Exists("D:Folder2" + aFile.Name))
{
File.Delete("D:Folder2" + aFile.Name);
}
aFile.MoveTo("D:Folder2" + aFile.Name);
}
}
Thank u .......its very helpful for me
ReplyDeleteThanks
ReplyDelete