Function File Names Class

CombinePathAndFile

Combine a path name with a file name, inserting the appropriate separator.

Signature (Visual Basic / VBA)

Public Function CombinePathAndFile( _
      ByVal vPath As Variant _
    , ByVal vFile As Variant _
    ) As Variant

Code Example

    CombinePathAndFile("",    "WINDOWS")  = "WINDOWS"
    CombinePathAndFile("C",   "WINDOWS")  = "C\WINDOWS" ' #2
    CombinePathAndFile("C",   "\WINDOWS") = "C\WINDOWS" ' #3
    CombinePathAndFile("C:",  "WINDOWS")  = "C:WINDOWS"
    CombinePathAndFile("C:",  "\WINDOWS") = "C:\WINDOWS"
    CombinePathAndFile("C:\", "WINDOWS")  = "C:\WINDOWS"
    CombinePathAndFile("C:\", "\WINDOWS") = "C:\WINDOWS"
    CombinePathAndFile("\\SJS4\C",  "")          = "\\SJS4\C"
    CombinePathAndFile("\\SJS4\C",  "ENTISOFT")  = "\\SJS4\C\ENTISOFT"
    CombinePathAndFile("\\SJS4\C",  "\ENTISOFT") = "\\SJS4\C\ENTISOFT"
    CombinePathAndFile("\\SJS4\C\", "ENTISOFT")  = "\\SJS4\C\ENTISOFT"
    CombinePathAndFile("\\SJS4\C\", "\ENTISOFT") = "\\SJS4\C\ENTISOFT"

Parameters

Parameter Description
vPath The drive and/or directory path portions of a file name. Function returns Null if vPath is Null or cannot be fixed-up to a string.
vFile The file prefix and/or extension portions of a file name. Function returns Null if vFile is Null or cannot be fixed-up to a string.

Notes & Version History

Note Similar to the CombineDriveAndPath function except in cases where the first argument is a single letter as in examples #2 and #3.