|
-
Aug 2nd, 2001, 10:32 AM
#1
Thread Starter
PowerPoster
DOS File Names
This is related to
http://forums.vb-world.net/showthrea...threadid=93712
but I didnt want to hijack the thread.
I know from the above thread that you can convert a long file name to a dos file name.
Is there a way to convert a dos file name to a long file name (assuming there is a corresponding long name)?
Thanks
-
Aug 2nd, 2001, 10:42 AM
#2
PowerPoster
Yep, the GetFullPathName API...
VB Code:
Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
http://www.allapi.net/api/api158.php
-
Aug 2nd, 2001, 11:22 AM
#3
Thread Starter
PowerPoster
Thanks!
Cant seem to get a test to work. Any idea whats wrong?
VB Code:
Private Declare Function GetFullPathName Lib "kernel32" _
Alias "GetFullPathNameA" (ByVal lpFileName As String, _
ByVal nBufferLength As Long, ByVal lpBuffer As String, _
ByVal lpFilePart As String) As Long
Private Sub Command2_Click()
Dim Buffer As String, Ret As Long
Buffer = Space(255)
Ret = GetFullPathName("C:\MYDOCU~1\BOOK1.XLS", 255, Buffer, "")
Buffer = Left(Buffer, Ret)
Text4.Text = Buffer
End Sub
-
Aug 2nd, 2001, 11:25 AM
#4
PowerPoster
Try this example...
VB Code:
Public Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long
Public Function GetLongFilename(ByVal sShortFilename As String) As String
Dim lRet As Long
Dim sLongFilename As String
sLongFilename = String$(1024, " ")
lRet = GetLongPathName(sShortFilename, sLongFilename, Len(sLongFilename))
If lRet > Len(sLongFilename) Then
sLongFilename = String$(lRet + 1, " ")
lRet = GetLongPathName(sShortFilename, sLongFilename, Len(sLongFilename))
End If
If lRet > 0 Then
GetLongFilename = Left$(sLongFilename, lRet)
End If
End Function
Courtesy of Matt...
-
Aug 2nd, 2001, 11:52 AM
#5
Thread Starter
PowerPoster
Works great!
Thanks Chrijk (and Matt)!!!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|