VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert Long File Location And Name To Short

by CovertLoop (12 Submissions)
Category: Coding Standards
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This code enables you to convert a long file location and filename to a short file location and filename. Example: C:\Program Files\Test.txt
will become C:\Progra~1\Test.txt

API Declarations
ADD TO A MODULE
Declare Function GetShortPathName Lib "kernel32" Alias _
"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal _
lpszShortPath As String, ByVal cchBuffer As Long) As Long

Rate Convert Long File Location And Name To Short

Add The Declarations Above To A Module. Then put this whenever you want to perform the conversion:
Dim sFile As String, sShortFile As String * 67
Dim lRet As Long
sFile = "C:\Program Files\Test.txt" 'Long File Location/Name
lRet = GetShortPathName(sFile, sShortFile, Len(sShortFile))
sFile = Left(sShortFile, lRet)
Text1.Text = sFile

Download this snippet    Add to My Saved Code

Convert Long File Location And Name To Short Comments

No comments have been posted about Convert Long File Location And Name To Short. Why not be the first to post a comment about Convert Long File Location And Name To Short.

Post your comment

Subject:
Message:
0/1000 characters