Board index » Visual Studio » FSO MoveFile Question

FSO MoveFile Question

Visual Studio0
I have a line of code that is supposed to move a file within the same

directory. I chose Move, because I thought in this instance it would be

similar to rename command. Basically what I wasnt to do is replace (c:\file)

with the file (c:\file.backup).



objFileSystem.MoveFile "c:\file.backup", "c:\file",True


-
 

Re:FSO MoveFile Question

15.01.2005 02:14, Yogi_Bear_79 schrieb:

Quote
I have a line of code that is supposed to move a file within the same

directory. I chose Move, because I thought in this instance it would be

similar to rename command. Basically what I wasnt to do is replace (c:\file)

with the file (c:\file.backup).



objFileSystem.MoveFile "c:\file.backup", "c:\file",True



MoveFile has no 3rd paramter for overwriting or whatever, although it

would be useful.

You can use either Move/MoveFile for renaming. But you

change the time-attributes of the file by doing so.



Also you can simply use the name-property for renaming



set File = objFileSystem.GetFile("c:\file")

File.Name = "file.backup"



If "file.backup" already exists, an error occurs, so you should check

this first with FileExists and handle it



Set File = objFileSystem.GetFile("c:\file")

If Not objFileSystem.FileExists("c:\file.backup") Then

objFileSystem.DeleteFile "file.backup"

Else

File.Name = "file.backup"











--

Gruesse, Christoph



Rio Riay Riayo - Gordon Sumner, 1979

-