C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C# programs » C# file handling programs

C# program to move file from one location to another location

In this C# program, we are going to learn how to move a file from one location to another location? To implement this, we are using ‘Move()’ method ‘File’ class.
Submitted by IncludeHelp, on November 03, 2017

Given a file, and we have to move it from one location to another location using C# program.


This is a method of "File class, which is used to move a file from one location (source) to another location (destination).


File.Move(source_file, dest_file);


  1. source_file - Location of source file.
  2. dest_file - Location of destination file, and here we can change filename.

We can set following detail of last write time:

  • Date
  • Month
  • Year
  • Hour
  • Minute
  • Second
  • AM/PM


using System;
using System.IO;

namespace ConsoleApplication1
    class Program
        static void Main()
            File.Move("source/ABC.TXT", "dest/XYZ.TXT");
            Console.WriteLine("File moved successfully");



File moved successfully

Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.

You may also be interested in...

C/C++ Tips and Tricks...

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions