Code:
'FileBACKUP_test.bas #Dim All Function BackupFile(ByVal SourceFile As String, ByVal DestinationFile As String) As Long 'this works, and is the ONLY way I've found to have the "backed up" file retain the original CreationTime stamp! Name SourceFile As DestinationFile 'the order of these two statements is counter-intuitive, BUT... FileCopy DestinationFile, SourceFile '...they accomplish the desired end result with ease! 'the logical alternatives involving API calls DO NOT work due to "file tunneling" as discussed in: 'http://www.powerbasic.com/support/pbforums/showthread.php?t=39340 '...teaser thread 'http://www.powerbasic.com/support/pbforums/showthread.php?t=39419 '...concise explanation (above) If Err Then MsgBox Str$(Err),,"Error during FileCopy" Function = 0 'failure Else Function = 1 'success End If End Function 'simple driver Function PBMain () As Long Local SourceFile, DestinationFile As String, RetVal As Long SourceFile = "c:\bat\MOVEME.txt" DestinationFile = "c:\copiedMOVEME2.txt" RetVal = BackupFile (SourceFile, DestinationFile) If RetVal Then MsgBox SourceFile & " ==> " & DestinationFile,,"File backup succeeded!" Else MsgBox SourceFile & " ==> " & DestinationFile,,"File backup failed!" End If 'compare the source and destination files' Creation Dates - they're the same! I don't know of any other way to do that! End Function
Leave a comment: