Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming a folder

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
0
0
US
I am looking for a way to rename a folder in a given directory using VB. So if I have C:\folder\folder\foldertorename I need to make it
C:\folder\folder\renamedfolder

Can I get a hint on where to look for my answer

thanks
 
Try this:
[tt]

Name "C:\folder\folder\foldertorename" As "C:\folder\folder\renamedfolder"
[/tt]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
OK, are there any objects I need to declare to do this?

thanks
 
I am not sure how to use what u suggested. I declared an object of FileSytemObject class. I see methods that copy from folder to folder, but I do not see anything that renames a folder. Something like
Name "C:\folder\folder\foldertorename" As "C:\folder\folder\renamedfolder"

will give an error. Any ideas?

thanks
 
Name works for me without any extra references, are you sure you have a folder at the location your trying to rename?
if you dont have a folder at "C:\folder\folder\foldertorename" (the path you are using) tehn Name will return a file not found error (53).
 
The Name statement is a native VB statement and requires no declarations. Check VBHelp for details. You do not need the FileSystemObject to use Name.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top