DateLastModified Property

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use the DateLastModified property to learn when the corresponding folder was last modified, that is, the date and time when any of the folder’s files was changed.

Declaration

aqFolderInfoObj.DateLastModified

Read-Only Property Date/Time
aqFolderInfoObj An expression, variable or parameter that specifies a reference to an aqFolderInfo object

Applies To

The property is applied to the following object:

Property Value

A Date object that contains the date the folder was last modified.

Example

The code below creates a folder, adds a file to it and then counts the number of the files located in the folder. After that, it posts the time when the folder was created, last modified and last accessed to the test log and deletes the folder.

JavaScript, JScript

function GetTimeExample()
{
 var sPath = "C:\\Temp";

 // Creates a folder
 aqFileSystem.CreateFolder(sPath);
 
 var FolderInf = aqFileSystem.GetFolderInfo(sPath);

 // Delays the script execution
 Delay(2000);
 
 // Adds a file to the folder
 aqFile.Create(sPath + "\\TempFile.txt");
 
 // Delays the script execution
 Delay(2000);
 
 // Obtains the number of files located in the C:\Temp folder
 Num = FolderInf.Files.Count;
 
 // Posts the time when the folder was created to the test log
 Log.Message( FolderInf.DateCreated );
 // Posts the folder's last write time to the test log
 Log.Message( FolderInf.DateLastModified );
 // Posts the folder's last access time to the test log
 Log.Message( FolderInf.DateLastAccessed );
 
 // Deletes the folder
 FolderInf.Delete(true);
}

Python

def GetTimeExample():
  sPath = "C:\\Temp"
  # Creates a folder
  aqFileSystem.CreateFolder(sPath)
  FolderInf = aqFileSystem.GetFolderInfo(sPath)
  # Delays the script execution
  Delay(2000)
  # Adds a file to the folder
  aqFile.Create(sPath + "\\TempFile.txt")
  # Delays the script execution
  Delay(2000)
  # Obtains the number of files located in the C:\Temp folder
  Num = FolderInf.Files.Count
  # Posts the time when the folder was created to the test log
  Log.Message(FolderInf.DateCreated)
  # Posts the folder's last write time to the test log
  Log.Message(FolderInf.DateLastModified)
  # Posts the folder's last access time to the test log
  Log.Message(FolderInf.DateLastAccessed)
  # Deletes the folder
  FolderInf.Delete(True)

VBScript

Sub GetTimeExample

 sPath = "C:\Temp"
 
 ' Creates a folder
 aqFileSystem.CreateFolder(sPath)
 
 Set FolderInf = aqFileSystem.GetFolderInfo(sPath)
 
 ' Delays the script execution
 Delay(2000)
 
 ' Adds a file to the folder
 aqFile.Create(sPath & "\TempFile.txt")
 
 ' Delays the script execution
 Delay(2000)
 
 ' Obtains the number of files located in the C:\Temp folder
 var Num = aqFileSystem.GetFolderInfo(sPath).Files.Count
 
 ' Posts the time when the folder was created to the test log
 Log.Message( FolderInf.DateCreated )
 ' Posts the folder's last write time to the test log
 Log.Message( FolderInf.DateLastModified )
 ' Posts the folder's last access time to the test log
 Log.Message( FolderInf.DateLastAccessed )
 
 ' Deletes the folder
 FolderInf.Delete(true)
 
End Sub

DelphiScript

function GetTimeExample;
var sPath, FolderInf, Num;
begin

 sPath := 'C:\Temp';

 // Creates a folder
 aqFileSystem.CreateFolder(sPath);
 
 FolderInf := aqFileSystem.GetFolderInfo(sPath);

 // Delays the script execution
 Delay(2000);
 
 // Adds a file to the folder
 aqFile.Create(sPath + '\TempFile.txt');
 
 // Delays the script execution
 Delay(2000);
 
 // Obtains the number of files located in the C:\Temp folder
 Num := FolderInf.Files.Count;
 
 // Posts the time when the folder was created to the test log
 Log.Message( FolderInf.DateCreated );
 // Posts the folder's last write time to the test log
 Log.Message( FolderInf.DateLastModified );
 // Posts the folder's last access time to the test log
 Log.Message( FolderInf.DateLastAccessed );
 
 // Deletes the folder
 FolderInf.Delete(true);
end;

C++Script, C#Script

function GetTimeExample()
{
 var sPath = "C:\\Temp";
 
 // Creates a folder
 aqFileSystem["CreateFolder"](sPath);
 
 var FolderInf = aqFileSystem["GetFolderInfo"](sPath);

 // Delays the script execution
 Delay(2000);
 
 // Adds a file to the folder
 aqFile["Create"](sPath + "\\TempFile.txt");
 
 // Delays the script execution
 Delay(2000);
 
 // Obtains the number of files located in the C:\Temp folder
 Num = FolderInf["Files"]["Count"];
 
 // Posts the time when the folder was created to the test log
 Log["Message"]( FolderInf["DateCreated"] );
 // Posts the folder's last write time to the test log
 Log["Message"]( FolderInf["DateLastModified"] );
 // Posts the folder's last access time to the test log
 Log["Message"]( FolderInf["DateLastAccessed"] );
 
 // Deletes the folder
 FolderInf["Delete"](true);
}

See Also

Working With Files From Scripts
GetFolderInfo Method
DateCreated Property
DateLastAccessed Property

Highlight search results