.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
satyapriyanayak
Subhransu Sekhar Jena
abhays
SP
DotnetUser

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Rename a file in .NET

Posted By:Praveen       Posted Date: April 22, 2009    Points: 10    Category: File Operation    URL:   
 

Rename the file using C# is not straight forward, but with simple trick we can achieve this. .NET framework provides File.Move() method to move file from one location to another using this method we can rename the file.

C# code sample

System.IO.File.Move(@"C:\FromFileName.txt", @"C:\TOFileName.txt");

in Vb.NET code example

System.IO.File.Move("C:\FromFileName.txt", "C:\TOFileName.txt")

 


     

Further Readings:

Responses
Author: Gaurav Arora         Company URL: http://www.msdotnetheaven.com/forums
Posted Date: April 26, 2009

Hi Praveen,

very nice jon

regards,
Gaurav Arora

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend