How To Move a Directory Using VB.NET

This article explains how to move a directory from one path to another path.
  • 2871

Move a directory in VB.NET

The Directory.Move method moves an existing directory to a new specified directory with full path. The Move method takes two parameters. The Move method deletes the original directory.
The following code snippet moves the source directory to the destination directory.

Imports System.IO

Module Module1

    Sub Main()

        Dim sourceDirName As String = "C:\Temp"

        Dim destDirName As String = "C:\NewTemp"

        Try

            Directory.Move(sourceDirName, destDirName)

        Catch exp As IOException

            Console.WriteLine(exp.Message)

        End Try

    End Sub

End Module

 

After executing above code you will see that all the existing directory moved to a new given directory with full path.

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.