[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

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
1 Solution
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
Is it just me or does the declare have the long and short values backwards?

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now