PDA

Click to See Complete Forum and Search --> : Long file names?


Athenis
Nov 22nd, 1999, 02:00 PM
Hi, How do I access files with LFNs? I always end up with an error.
Thanks.

Serge
Nov 22nd, 1999, 08:21 PM
You can convert long file names to short windows filenames (i.e. C:\Progra~1 etc)


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



Usage: ConverLongFileName FileToConvert

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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)