User Id :    Password :      New Member   Forgot Password  
 
How to copy or move a file from one location to another location in csharp
Description In this code snippet I will show you How to copy or move a file from one location to another location in csharp.   No. of Views     2847
  Rating     0
Author Najmul Hoda   Posted On     19 Oct 2010
Tags ASP.NET,C#    

Sample Code   Download Code

Introduction

In this code snippet I will show you how you can copy or move a file from one location to another location in charp.

 

To copy a file from one location to another location

File.Copy( "c:\\myFolder\\myFile.txt", "c:\\NewFolder\\myFile.txt");

If you want to change the name of the file while copying the file, use the code below.

File.Copy( "c:\\myFolder\\oldfile.txt", "c:\\NewFolder\\newfile.txt");

To move a file from one location to another location

File.Move( "c:\\myFolder\\myFile.txt", "c:\\NewFolder\\myFile.txt");

Same way as in the case of copy if you want to change the name of the file while copying the file, use the code below.

File.Move( "c:\\myFolder\\oldfile.txt", "c:\\NewFolder\\newfile.txt");

Enjoy Coding........

About Author

About Author He is a team lead, having 8+ years of experience. He loves writing technical article for .Net developers. Najmul Hoda
No Photo
 
Country United States
Company BirlaSoft
Home Page http://www.magixchat.com

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

 
 
Posted By Annonymous on 11 Aug 2011 at 07:17 AM
 
I think he should change his name to Honda
 
 
   
Write your comment here.
Comment
Verification Code