Search Tools Links Login

Convert Long File Location And Name To Short


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

Original Author: CovertLoop

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

Code

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 FilesTest.txt" 'Long File Location/Name
lRet = GetShortPathName(sFile, sShortFile, Len(sShortFile))
sFile = Left(sShortFile, lRet)
Text1.Text = sFile

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 80 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.