Renaming Folders

ftwomey
10-24-2002, 06:57 PM
Can anyone help me with the code to rename folders or move folders through VB?

Kaluriel
10-24-2002, 07:29 PM
Dim fso As New FileSystemObject
Dim sourcepath as string
Dim destpath as string

fso.MoveFolder(sourcepath,destpath)

that'll move and to rename:

Dim oldfldpath as string
Dim newfldpath as string

name oldfldpath as newfldpath

JDT
10-24-2002, 07:51 PM
In order to use the above exampe you will have to set a reference to Microsoft Scripting Runtime.

However, I would use the Name Statement to move and/or rename it.

This will take a folder from the desktop and move it and rename it to the C:\ drive. That is, if you have Win9x. If you have 2k then change it acordingly. It will also move the files in the folder:

Option Explicit

Private Sub Form_Load()
Name "C:\Windows\Desktop\New Folder" As "C:\Newer Folder"
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum