Page 1 of 1
MoveFile procedure
Posted: Fri Oct 15, 2010 10:46 pm
by wallgod
Code: Select all
Procedure.i MoveFile(file1.s, file2.s)
If Not CopyFile(file1, file2)
ProcedureReturn 0
EndIf
ProcedureReturn DeleteFile(file1)
EndProcedure
Debug MoveFile("c:\users\name\desktop\1.txt", "d:\backup\1.txt")
Re: MoveFile procedure
Posted: Fri Oct 15, 2010 10:49 pm
by ts-soft
You can use "RenameFile()", to move a file :roll:
Greetings
Thomas
Re: MoveFile procedure
Posted: Sat Oct 16, 2010 12:32 am
by PB
The problem with using CopyFile() is that it'll take forever with large files.
For example, your procedure with my AVI file of "Lord of the Rings" would
take about 3 minutes.
Now, as ts-soft said, if you use RenameFile() and both the source and
target files are on the SAME drive, the move is basically instant. My
"Lord of the Rings" file above moves in one second, but using CopyFile()
still takes about 3 minutes, both to the same or different drive.
Oh, and CopyFile() requires that the target drive has free disk space
that is the same size (or more) of the filed to be copied. RenameFile()
doesn't for same drives.
Re: MoveFile procedure
Posted: Sun Oct 17, 2010 4:26 am
by wallgod
Alright then! How about something like this (for Windows only)?
Code: Select all
Procedure MoveFile(file1.s, file2.s)
If Left(file1, FindString(file1, "\", 3)) = Left(file2, FindString(file2, "\", 3))
ProcedureReturn RenameFile(file1, file2)
EndIf
If Not CopyFile(file1, file2)
ProcedureReturn 0
EndIf
ProcedureReturn DeleteFile(file1)
EndProcedure
...or is there a better way to check the drive of a file specification?