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”)

Leave a comment