How to Return Short path for given file (with long path)
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 'File/Folder Handling - How to Return Short path for given file (with long path) Option Explicit Private Declare Function GetShortPathNameA Lib "kernel32" (ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Public Function GetShortPathName(ByVal sLongPath As String) As String Dim s As String Dim I As Long i = Len(sLongPath) + 1 s = String(i, 0) GetShortPathNameA sLongPath, s, i GetShortPathName = Left$(s, InStr(s, Chr$(0)) - 1) End Function 'How can I call this function: 'Debug.Print GetShortPathName("c:\Program Files\") 'Will return c:\PROGRA~1\ |
Related posts:
- How to retrieve the full long path name from short path (MS Dos format)
- How to Convert Long file names to Short file names
- How to Return the path of a given full path to a file
- How to Return the filename of a given full path to a file
- How to get the file path for the selected file using Common Dialog control
- How to Return the Path portion of a file (in two ways)
- How to get file name alone from a file name with its full path
- How to return the path to the windows directory.
- How to return the path to the system directory.
- How to get the file name without its extension and path