Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Long File Names

6 views
Skip to first unread message

Thomas Bonnes

unread,
Jul 31, 2001, 7:49:29 PM7/31/01
to

I remember there is a function routine to obtain the long file name from a
dos
name.. I think it's an API, but I don't have Applemen's book handy. Such
as I have a file path comes back to my program like this:

C:\winnt\profiles\........\F0860 C~1

from the VB command() statement..

I want to extract out a folder name like this:

"F0860 Con"


I will use this logic to get rid of the rest of path.. but I need to get the
real path name:
right(FilePath, len(filepath) - InstrRev(FilePath, "\") )

Thanks,
Tom Bonnes


Thomas Bonnes

unread,
Aug 1, 2001, 5:17:33 PM8/1/01
to
> I have a file path comes back to my program like this:
> C:\winnt\profiles\........\F0860 C~1
> from the VB command() statement..
> I want to extract out a folder name like this:
> "F0860 Con"

It looks like I found my answer at the Microsoft site. This VB routine
seems to work good for me. I read in Applemans book that the API has some
big problems in VB, so this is the best fix..

Tom

=======================================
Function GetLongFN(ByVal sShortName As String) As String

Dim sLongName As String, sTemp As String, iSlashPos As Integer

'Add \ to short name to prevent Instr from failing
sShortName = sShortName & "\"
'Start from 4 to ignore the "[Drive Letter]:\" characters
iSlashPos = InStr(4, sShortName, "\")
'Pull out each string between \ character for conversion

While iSlashPos
sTemp = Dir(Left$(sShortName, iSlashPos - 1), vbNormal +
vbHidden + vbSystem + vbDirectory)
If sTemp = "" Then 'Error 52 - Bad File Name or
Number
GetLongFN = ""
Exit Function
End If
sLongName = sLongName & "\" & sTemp
iSlashPos = InStr(iSlashPos + 1, sShortName, "\")
Wend
'Prefix with the drive letter
GetLongFN = Left$(sShortName, 2) & sLongName
End Function
=================================


0 new messages