Previous Topic: GetFileTime - Return File Creation Date, Last Access Date, or Last Modified DateNext Topic: GetShortFileName - Convert Long File Name to Short File Name


GetLongFileName - Convert Short File Name to Long File Name

Valid on Windows

The GetLongFileName function converts the short file name to the long file name.

Function format:

GetLongFileName(shortFileName as string, longFileName as string) as Boolean
shortFileName

An input parameter. It is the MS DOS 8.3 file name to be expanded into a long file name format.

longFileName

An output parameter and receives the long, expanded file name.

On successful execution, the function returns TRUE; otherwise, it returns FALSE. To convert a file name, the related file must exist on the system or the function fails.

Example:

This example converts a long file name into a short one and converts it back.

Dim lName, oName, sName As String
ClrScr()

oName ="c:\temp\a bb ccc dddd\abcdefghijklmnopqrstuvwxyz.txt"
If Not(GetShortFileName(oName, sName)) Then
	MessageBox("Can not convert to short", "DMS", MB_OK + MB_ICONEXCLAMATION)
	SetStatus(1)
	Exit
End If
Print( oName + " - " + sName)
If Not(GetLongFileName(sName, lName)) Then
	MessageBox("Can not convert to long", "DMS", MB_OK + MB_ICONEXCLAMATION)
	SetStatus(2)
	Exit
End If
Print( sName + " - " + lName)