How to rename a file in VB C#

I saw many guys looking for rename method in IO.FIle which does not exists so how i can rename a file. .Net got different approaches for c# and vb.net

How to rename a file in C#

System.IO.File.Move(@”C:\Tarun\test1.txt”, @”C:\Tarun\test2.txt”);

How to rename a file in VB

My.Computer.FileSystem.RenameFile(“C:\Test.txt”, “SecondTest.txt”)

Or

My.Computer.FileSystem.MoveFile(“C:\Tarun\test1.txt”, “C:\Tarun\test2.txt”)

Or

System.IO.File.Move(“C:\Tarun\test1.txt”, “C:\Tarun\test2.txt”)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s