How to Rename Folders in Visual Basic

How to Rename Folders in Visual Basic thumbnail
You can rename folders using the RenameDirectory method in Visual Basic.

In Visual Basic (VB), you can rename folders by using the "RenameDirectory" method and supplying the directory path and new name for the directory. This method is part of the "My.Computer.FileSystem" object in VB. To rename many folders, you can simply duplicate the code with different folder paths and folder names.

Things You'll Need

  • Microsoft Visual Basic Express
Show More

Instructions

    • 1

      Launch Microsoft Visual Basic Express. Click "New Project..." on the left pane of your screen. Click "Visual Basic" below "Installed Templates." Double-click "Console Application" to create a new console project.

    • 2

      Copy and paste the following code to declare two variables:

      Dim OldFolderName As String

      Dim NewFolderName As String

    • 3

      Copy and paste the following code to define the file path and new name:

      OldFolderName = "C:\Folder"

      NewFolderName = "NewFolderName"

    • 4

      Copy and paste the following code to rename the file:

      FileIO.FileSystem.RenameDirectory(OldFolderName, NewFolderName)

    • 5

      Press "F5" to run your program and rename the folder.

Related Searches:

References

  • Photo Credit Medioimages/Photodisc/Photodisc/Getty Images

Comments

You May Also Like

Related Ads

Featured