Finding the short filename from a long filename
If you're working in the 32-bit world, your user will sometimes give you a long filename to work with. If you really want to see the short filename, not the long one, you can use the GetShortPathName function:
Author: Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" _ (ByVal LongName As String, ShortName As String, ByVal bufsize As Integer) As Long Public Function ShortFileName (ByVal LongFileName As String) As String Dim dummy As String Dim length As Long dummy = Space(20) ' Allocate space for 1 short filename (12345678.123) and then some ' Retrieve short filename from long filename length = GetShortPathName(LongFileName, dummy, Len(dummy)) If length > 0 Then ShortFileName = Left(dummy, length) End Function |
||
Editor: Last update: 2024-12-26 Copyright 1995-2024 VBI |