Next File.Move uses system routines to attempt to change the name of the first file to the name of the second file.
So If successful, the first file will no longer exist. If unsuccessful, the operation will be terminated—nothing will be changed on disk.
static void Main()
//// Move a file found on the C:\ volume.// If the file is not found (SAM.txt doesn't exist),// then you will get an exception.//
File.Move(@"C:\SAM.txt", @"C:\SAMUEL.txt"); // Try to move
Console.WriteLine("Moved"); // Success
catch (IOException ex)
Console.WriteLine(ex); // Write error
}System.IO.FileNotFoundException: Could not find file 'C:\SAM.txt'.
File name: 'C:\SAM.txt'
Exceptions. Whenever you are dealing with the file system, errors will occur. You must be prepared to recover from these errors (even if recovery means exiting).