Coping all files from one folder to another folder in Dot Net using C#.

Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 176
Again import System.IO Namespace:-
using System.IO;

string sourcePath = @"C:\ABC";
string targetPath = @"C:\ABC_COPY";
if (!Directory.Exists(targetPath))
foreach (var srcPath in Directory.GetFiles(sourcePath))
//Copy the file from sourcepath and place into mentioned target path,
//Overwrite the file if same file is exist in target path
File.Copy(srcPath,srcPath.Replace(sourcePath, targetPath),true);

Comments or Responses

Login to post response