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

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: http://www.dotnetspark.com  

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:

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

Hi Praveen,

very nice jon

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