You must Sign In to post a response.
  • Category: Windows 10

    Copy file from one location to another

    We have a excel/csv file which has two columns and 10000 records, these are file path index.
    id name filelocation
    1 lab \\archive\folder1\test1.tif
    2 lab \\archive\folder2\test3.tif

    the \\archive\ folder has somany subfolders and files , that total files count 120000. I have to copy only 10000 records as per excel index to a new location , that means new location should be contain only indexed files. (not extra files). how to achive these please let me know the idea?
  • #770408
    To copy a file from its present location to a new one, use the File.Copy method. The file name can also be changed. The Python snippet below reads every file in the Your Path folder.

    Note: Change "Your Path" to the complete path of the directory you wish to relocate, and "Your Destination" to the complete path of your new location.
    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);

  • Sign In to post your comments