File.Move() Method in C#



File.Move() is an inbuilt File class method that is used to move a specified file to a new location. This method also provides the option to specify a new file name

  1. using System;   
  2. using System.IO;   
  3.     
  4. class Example {   
  5.     static void Main()   
  6.     {   
  7.         try {   
  8.             // Moving the file file.txt to location C:\gfg.txt   
  9.             File.Move(@"file1.txt", @"C:\file11.txt");   
  10.             Console.WriteLine("Moved");   
  11.         }   
  12.         catch (IOException ex) {   
  13.             Console.WriteLine(ex);   
  14.         }   
  15.     }   
  16. }   
file moved to a new location
 
 
 
 
 

0 Comment's

Comment Form

Submit Comment