Copy files from one directory to another

Step 1. Add following namespace

using System.IO;

Step 2. Use this code

public void readfiles()
{
    string[] filePaths = Directory.GetFiles("Your Path");
    foreach (var filename in filePaths)
    {
        string file = filename.ToString();
                
        //Do your job with "file"

        string str = "Your Destination"+file.ToString(),Replace("Your Path");
        if (!File.Exists(str))
        {
            File.Copy(file , str);
        }
    }
}
Ebook Download
View all
Learn
View all