Hi, How do I access files with LFNs? I always end up with an error.
Thanks.
Printable View
Hi, How do I access files with LFNs? I always end up with an error.
Thanks.
You can convert long file names to short windows filenames (i.e. C:\Progra~1 etc)
Usage: ConverLongFileName FileToConvertCode:Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Function ConverLongFileName(pstrFileName As String) As String
Dim strBuffer As String
Dim lRet As Long
strBuffer = Space(255)
lRet = GetShortPathName(pstrFileName, strBuffer, Len(strBuffer))
If lRet = 0 Then
ConverLongFileName = pstrFileName
Else
ConverLongFileName = Left(strBuffer, lRet)
End If
End Function
Sample:
Dim strFile As String
strFile = ConverLongFileName("C:\WINNT\Media\The Microsoft Sound.wav")
strFile in my case would be: C:\WinNT\Media\THEMIC~1.WAV
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819