How to convert "short" filename to "long" filename.

In VB how to I take the short filename if I have it and convert it to its longfilename?
ex. myfile~1.exe  --> myfilename.exe
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Private Declare Function OSGetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

'Function: GetLongPath(ByVal strShortPath As String) As String
'Description: Retrieve the long pathname version of a path possibly
'             containing short subdirectory and/or file names
Function sGetLongFileName(ByVal ShortPath As String) As String

  Dim LongPath As String * 300
  Dim rc As Long
  On Local Error Resume Next
  rc = OSGetLongPathName(ShortPath, LongPath, 300)
  If (rc = 0) Then
    Error 53 ' File not found
    sGetLongFileName = ShortPath
    sGetLongFileName = StripNull(LongPath)
  End If
End Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Is it just me or does the declare have the long and short values backwards?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.