<-- Previous || Up || Next -->

Name Backup Target Function
File Operations Class

Public Function NameBackupTarget( _
      ByVal vFromFileName As Variant _
    , ByVal vToFileName As Variant _
    ) As Boolean

Rename a file and keep a backup of the target file if the target file already exists.
Backup file has same name as target file except that last character is changed to a hyphen ("-").

Example:
    StringToFile("First.", "Debug.Out") = True
    NameBackupTarget("Debug.Out", "Debug.1") = True
    StringToFile("Second.", "Debug.Out") = True
    ' Next call renames Debug.1 to Debug.-
    ' then renames Debug.Out to Debug.1
    NameBackupTarget("Debug.Out", "Debug.1") = True
    FileToString("Debug.1") = "Second."
    FileToString("Debug.-") = "First."
See also:
    NameAsBackup Function
    NameMaybeBackupInTemp Function
vFromFileName: Current name of the file; the name that is to be changed. Function does nothing and returns False if vFromFileName is Null or cannot be fixed-up to a String.
vToFileName: New name for the file; the name that it will be changed to. Function does nothing and returns False if vToFileName is Null or cannot be fixed-up to a String. If the last character of vToFileName is already a hyphen, then no backup is kept.
v1.2 BugFix: Changed the argument types from String to Variant to be more consistent with the other functions in this Class.
v1.2 Change: Changed to use the Visual Basic FileCopy statement so that vFromFileName and vToFileName no longer have to reside on the same drive.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.