ShortPath Property

Applies to TestComplete 14.80, last modified on April 15, 2021

Description

The ShortPath property returns a shortened version of a full file path (with the file’s name and extension). If this format is used, the names of files and folders do not exceed 8 characters, and the extensions are not longer than 3 characters. This naming convention was adopted in MS-DOS.

Declaration

aqFileInfoObj.ShortPath

Read-Only Property String
aqFileInfoObj An expression, variable or parameter that specifies a reference to an aqFileInfo object

Applies To

The property is applied to the following object:

Property Value

A string containing the shortened path (with the file’s name and extension).

Example

The code below obtains the short path of the specified file and posts this path to the test log.

JavaScript, JScript

function ShortPathExample()
{

  // Specifies the fully qualified file name
  var sPath = "C:\\FolderName\\FileLongName.txt";
  
  // Obtains the file's short path
  var sShortPath = aqFileSystem.GetFileInfo(sPath).ShortPath;
  
  // Posts the file's short path to the test log
  Log.Message("The file's short path is: " + sShortPath);
  
}

/*
The routine produces the following output:

The file's short path is: C:\FOLDER~1\FILELO~1.TXT
*/

Python

def ShortPathExample():
  # Specifies the fully qualified file name 
  sPath = "C:\\FolderName\\FileLongName.txt"
  # Obtains the file's short path 
  sShortPath = aqFileSystem.GetFileInfo(sPath).ShortPath
  # Posts the file's short path to the test log 
  Log.Message("The file's short path is: " + sShortPath)

# The routine produces the following output: 
# The file's short path is: C:\FOLDER~1\FILELO~1.TXT

VBScript

Sub ShortPathExample

  ' Specifies the fully qualified file name
  sPath = "C:\FolderName\FileLongName.txt"
  
  ' Obtains the file's short path
  sShortPath = aqFileSystem.GetFileInfo(sPath).ShortPath
  
  ' Posts the file's short path to the test log
  Log.Message("The file's short path is: " + sShortPath)
  
End Sub

' The routine produces the following output:
' The file's short path is: : C:\FOLDER~1\FILELO~1.TXT

DelphiScript

function ShortPathExample;
var sPath, sShortPath;
begin

  // Specifies the fully qualified file name
  sPath := 'C:\FolderName\FileLongName.txt';
  
  // Obtains the file's short path
  sShortPath := aqFileSystem.GetFileInfo(sPath).ShortPath;
  
  // Posts the file's short path to the test log
  Log.Message('The file''s short path is: ' + sShortPath);
  
end;

{
The routine produces the following output:

The file's short path is: C:\FOLDER~1\FILELO~1.TXT
}

C++Script, C#Script

function ShortPathExample()
{

  // Specifies the fully qualified file name
  var sPath = "C:\\FolderName\\FileLongName.txt";
  
  // Obtains the file's short path
  var sShortPath = aqFileSystem["GetFileInfo"](sPath)["ShortPath"];
  
  // Posts the file's short path to the test log
  Log["Message"]("The file's short path is: " + sShortPath);
  
}

/*
The routine produces the following output:

The file's short path is: C:\FOLDER~1\FILELO~1.TXT
*/

See Also

Working With Files From Scripts
GetFileInfo Method
FindFiles Method
Name Property
Path Property
GetShortPathName Method

Highlight search results