Rename a Folder

F

F@yy@Z

Hi All

I am using FSO to manage Folders and files.
Set fso = CreateObject("Scripting.FileSystemObject")
strRet = fso.MoveFolder (cstr(strSource),cstr(strDestination))
Set fso = Nothing

As there is no rename option in FSO so I have to use MoveFolder () to rename
a folder.

It renaming the folder if folder do not have any containing (child) folder,
if there is any folder inside to that folder it gives error "permission
denied"
Any suggestion ?


Regards

Fayyaz
 
R

Ray at

Set the name property. It's read/write.

Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(strSource)
oFolder.Name = CStr(strDestination)
Set oFolder = Nothing
Set fso = Nothing

Ray at work
 
F

F@yy@Z

I tried this and giving me this Error.

Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument at line below.

oFolder.Name = CStr(strDestination)

Regards
Fayyaz
 
R

Ray at

What's the value of strDestination?

What does your whole code snippet look like?

As long as strSource and strDestination are valid, the code should be okay
(barring external factors like NTFS permissions and what not).

Ray at work
 
F

F@yy@Z

Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(CStr("c:\test"))
MsgBox oFolder.Name
oFolder.Name = ("c:\test1")
Set oFolder = Nothing
Set fso = Nothing


I tried this above code in VB and its giving me the same error.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top