Function File Operations Class

NameAsBackup

Rename a file by replacing the last character of the name with a hyphen ("-").

Signature (Visual Basic / VBA)

Public Function NameAsBackup( _
    ByVal vFromFileName As Variant _
    ) As Boolean

Code Example

    StringToFile("First.", "Debug.Out") = True
    ' Next call renames Debug.Out to Debug.Ou-
    NameAsBackup("Debug.Out") = True
    FileToString("Debug.Ou-") = "First."

Parameters

Parameter Description
vFromFileName Name of the file that is to be renamed. The file is renamed by changing the last character of its name to a hyphen. Function returns False if vFromFileName is Null or cannot be fixed-up to a String.

Return Value

Function returns True if the file was successfully renamed. Function returns False if the argument cannot be fixed-up or if there is an error renaming the file.

Notes & Version History

Note If vFromFileName already ends with a hyphen, then the file name is not changed.
v1.2 BugFix Changed the argument type from String to Variant to be more consistent with the other functions in this Class.