move file c#

56

move file from one folder to another c# -

 //take all files of main folder to folder model_RCCMrecTransfered 
            string rootFolderPath = @"F:/model_RCCMREC/";
            string destinationPath = @"F:/model_RCCMrecTransfered/";
            string filesToDelete = @"*_DONE.wav";   // Only delete WAV files ending by "_DONE" in their filenames
            string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete);
            foreach (string file in fileList)
            {
                string fileToMove = rootFolderPath + file;
                string moveTo = destinationPath + file;
                //moving file
                File.Move(fileToMove, moveTo);

move file c# -

for (int i = 1; i < n; i++)
{
    try
    {
        from = System.IO.Path.Combine(@"E:\vid\","(" + i.ToString() + ").PNG");
        to = System.IO.Path.Combine(@"E:\ConvertedFiles\",i.ToString().PadLeft(6,'0') + ".png");

        File.Move(from, to); // Try to move
        Console.WriteLine("Moved"); // Success
    }
    catch (IOException ex)
    {
        Console.WriteLine(ex); // Write error
    }
}

Comments

Submit
0 Comments