CodeItBetter Programming Another VB Programming Blog

How to Move Folder from one directory to another (in two ways)

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'File/Folder Handling - How to Move Folder from one directory to another (in two ways)
'Using FSO:

Public Sub MoveFolderUsingFSO(ByVal sOldFolderName As String, ByVal sNewFolderName As String)
'Set a reference to "Microsoft Scripting Runtime"
    Dim FSO As Scripting.FileSystemObject
    Set FSO = New Scripting.FileSystemObject
    FSO.MoveFolder sOldFolderName, sNewFolderName
    Set FSO = Nothing
End Sub
 
'Using Move Dos Command:

Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long
 
Public Sub MoveFolderUsingMove(ByVal sSourceFolder As String, ByVal sDestinationFolder As String)
    Dim sCommand As String
    Call MakeSureDirectoryPathExists(sDestinationFolder)
    sCommand = "Cmd.exe /C Move " & ChrW$(34) & sSourceFolder & ChrW$(34) & " " & ChrW$(34) & _
        sDestinationFolder & ChrW$(34)
    Debug.Print sCommand
    Shell sCommand
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.