OriginalFilename Property

Applies to TestComplete 14.93, last modified on October 12, 2021

Description

The OriginalFilename property returns the original name of the file (without the path). This is the name that the file was created with. So, you can use this property to check if the file has been renamed.

Declaration

aqFileVersionInfoObj.OriginalFilename(Index)

Read-Only Property String
aqFileVersionInfoObj An expression, variable or parameter that specifies a reference to an aqFileVersionInfo object
Index [in]    Optional    Integer Default value: 0   

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

A file can contain multiple version information blocks translated in different languages. This parameter specifies a zero-based index of the desired version information translation, among those included in the file. The default value is 0, which means the default version information block. To get the total number of version information translations in a file, use the Languages property.

Property Value

A string that holds the file’s original name.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the OriginalFilename property in square brackets: OriginalFilename[Index].

Example

The code below renames the notepad.exe file, posts its original name to the test log and then renames the file back.

JavaScript, JScript

function OriginalFileNameExample()
{
   
   // Specifies the file's name
   var OldName = Sys.OSInfo.SystemDirectory + "\\notepad.exe";
   
   // Specifies the file's new name
   var NewName = Sys.OSInfo.SystemDirectory + "\\notepad1.exe";
   
   // Renames the file
   aqFile.Rename(OldName, NewName);
   
   // Obtains information about the file's version
   var vInfo = aqFileSystem.GetFileInfo(NewName).VersionInfo;
   
   // Posts the original file name to the test log
   Log.Message("The original file name is: " + vInfo.OriginalFilename);
   
   if (vInfo.OriginalFilename == OldName)
     Log.Message("The file was not renamed.");
   else
     Log.Message("The file was renamed.");
   
   // Sets the original name of the file
   aqFile.Rename(NewName, vInfo.OriginalFilename);

}

/*
The routine produces the following output:

The original file name is: NOTEPAD.EXE
The file was renamed.
*/

Python

def OriginalFileNameExample():
  # Specifies the file's name
  OldName = Sys.OSInfo.SystemDirectory + "\\notepad.exe"
  # Specifies the file's new name
  NewName = Sys.OSInfo.SystemDirectory + "\\notepad1.exe"
  # Renames the file 
  aqFile.Rename(OldName, NewName)
  # Obtains information about the file's version
  vInfo = aqFileSystem.GetFileInfo(NewName).VersionInfo
  # Posts the original file name to the test log
  Log.Message("The original file name is: " + str(vInfo.OriginalFilename[0]))
  if vInfo.OriginalFilename == OldName:
    Log.Message("The file was not renamed.")
  else:
    Log.Message("The file was renamed.")
  # Sets the original name of the file
  aqFile.Rename(NewName, vInfo.OriginalFilename[0])

# The routine produces the following output: 
# The original file name is: NOTEPAD.EXE
# The file was renamed.

VBScript

Sub OriginalFileNameExample
   
   ' Specifies the file's name
   OldName = Sys.OSInfo.SystemDirectory + "\notepad.exe"
   
   ' Specifies the file's new name
   NewName = Sys.OSInfo.SystemDirectory + "\notepad1.exe"
   
   ' Renames the file
   Call aqFile.Rename(OldName, NewName)
   
   ' Obtains information about the file's version
   Set vInfo = aqFileSystem.GetFileInfo(NewName).VersionInfo
   
   ' Posts the original file name to the test log
   Log.Message("The original file name is: " + vInfo.OriginalFilename)
   
   If (vInfo.OriginalFilename = OldName) Then
     Log.Message("The file was not renamed.")
   Else
     Log.Message("The file was renamed.")
   End If
   
   ' Sets the original name of the file
   Call aqFile.Rename(NewName, vInfo.OriginalFilename)

End Sub

' The routine produces the following output:

' The original file name is: NOTEPAD.EXE
' The file was renamed.

DelphiScript

function OriginalFileNameExample;
var OldName, NewName, vInfo;
begin

   
   // Specifies the file's name
   OldName := Sys.OSInfo.SystemDirectory + '\\notepad.exe';
   
   // Specifies the file's new name
   NewName := Sys.OSInfo.SystemDirectory + '\\notepad1.exe';
   
   // Renames the file
   aqFile.Rename(OldName, NewName);
   
   // Obtains information about the file's version
   vInfo := aqFileSystem.GetFileInfo(NewName).VersionInfo;
   
   // Posts the original file name to the test log
   Log.Message('The original file name is: ' + vInfo.OriginalFilename);
   
   if (vInfo.OriginalFilename = OldName) then
     Log.Message('The file was not renamed.')
   else
     Log.Message('The file was renamed.');
   
   // Sets the original name of the file
   aqFile.Rename(NewName, vInfo.OriginalFilename);

end;

{
The routine produces the following output:

The original file name is: NOTEPAD.EXE
The file was renamed.
}

C++Script, C#Script

function OriginalFileNameExample()
{
   
   // Specifies the file's name
   var OldName = Sys["OSInfo"]["SystemDirectory"] + "\\notepad.exe";
   
   // Specifies the file's new name
   var NewName = Sys["OSInfo"]["SystemDirectory"] + "\\notepad1.exe";
   
   // Renames the file
   aqFile["Rename"](OldName, NewName);
   
   // Obtains information about the file's version
   var vInfo = aqFileSystem["GetFileInfo"](NewName)["VersionInfo"];
   
   // Posts the original file name to the test log
   Log["Message"]( "The original file name is: " + vInfo["OriginalFilename"] );
   
   if (vInfo["OriginalFilename"] == OldName)
     Log["Message"]("The file was not renamed.");
   else
     Log["Message"]("The file was renamed.");
   
   // Sets the original name of the file
   aqFile["Rename"]( NewName, vInfo["OriginalFilename"] );

}

/*
The routine produces the following output:

The original file name is: NOTEPAD.EXE
The file was renamed.
*/

See Also

InternalName Property
Languages Property

Highlight search results