Previous Topic: GetLongFileName - Convert Short File Name to Long File NameNext Topic: GetSpecialDir - Get the Special Directory Name and Path


GetShortFileName - Convert Long File Name to Short File Name

Valid on Symbian OS and Windows

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

Function format:

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

This is an input parameter. It is the file name to be converted into a short file name (8.3 notation).

shortFileName

This is an output parameter and receives the converted file name.

On successful execution, this 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)