DateLastAccessed Property

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the DateLastAccessed property to learn when the corresponding file was last accessed.

Declaration

aqFileInfoObj.DateLastAccessed

Read-Only Property Date/Time
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

Use the DateLastAccessed property to learn when the corresponding file was last accessed.

Example

The code below creates a file, writes some data to it and reads the file's content. After that, it posts the time when the file was created, last modified and last accessed to the test log and deletes the file.

JavaScript, JScript

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

 // Creates a file
 aqFile.Create(sPath);
 
 var FileInf = aqFileSystem.GetFileInfo(sPath);

 // Delays the script execution
 Delay(2000);
 
 // Writes data to the file
 FileInf.WriteToTextFile("Hello, World!", aqFile.ctANSI);
 
 // Delays the script execution
 Delay(2000);
 
 // Reads the file's content
 FileInf.ReadWholeTextFile(aqFile.ctANSI);
 
 // Posts the file's creation time to the test log
 Log.Message( FileInf.DateCreated );
 // Posts the file's last write time to the test log
 Log.Message( FileInf.DateLastModified );
 // Posts the file's last access time to the test log
 Log.Message( FileInf.DateLastAccessed );
 
 // Deletes the file
 FileInf.Delete();
}

Python

def GetTimeExample():
  sPath = "C:\\Temp\\TempFile.txt"
  # Creates a file
  aqFile.Create(sPath)
  FileInf = aqFileSystem.GetFileInfo(sPath)
  # Delays the script execution
  Delay(2000)
  # Writes data to the file
  FileInf.WriteToTextFile("Hello, World!", aqFile.ctANSI);
  # Delays the script execution
  Delay(2000)
  # Reads the file's content
  FileInf.ReadWholeTextFile(aqFile.ctANSI)
  
  # Posts the file's creation time to the test log
  Log.Message(FileInf.DateCreated)
  # Posts the file's last write time to the test log
  Log.Message(FileInf.DateLastModified)
  # Posts the file's last access time to the test log
  Log.Message(FileInf.DateLastAccessed)
  
  # Deletes the file
  FileInf.Delete()

VBScript

Sub GetTimeExample

 sPath = "C:\Temp\TempFile.txt"

 ' Creates a file
 Call aqFile.Create(sPath)
 
 Set FileInf = aqFileSystem.GetFileInfo(sPath)

 ' Delays the script execution
 Call Delay(2000)
 
 ' Writes data to the file
 Call FileInf.WriteToTextFile("Hello, World!", aqFile.ctANSI)
 
 ' Delays the script execution
 Call Delay(2000)
 
 ' Reads the file's content
 Call FileInf.ReadWholeTextFile(aqFile.ctANSI)
 
 ' Posts the file's creation time to the test log
 Call Log.Message( FileInf.DateCreated )
 ' Posts the file's last write time to the test log
 Call Log.Message( FileInf.DateLastModified )
 ' Posts the file's last access time to the test log
 Call Log.Message( FileInf.DateLastAccessed )
 
 ' Deletes the file
 Call FileInf.Delete()
End Sub

DelphiScript

function GetTimeExample;
 var sPath, FileInf;

begin
 sPath := 'C:\Temp\TempFile.txt';

 // Creates a file
 aqFile.Create(sPath);
 
 FileInf := aqFileSystem.GetFileInfo(sPath);

 // Delays the script execution
 Delay(2000);
 
 // Writes data to the file
 FileInf.WriteToTextFile('Hello, World!', aqFile.ctANSI);
 
 // Delays the script execution
 Delay(2000);
 
 // Reads the file's content
 FileInf.ReadWholeTextFile(aqFile.ctANSI);
 
 // Posts the file's creation time to the test log
 Log.Message( FileInf.DateCreated );
 // Posts the file's last write time to the test log
 Log.Message( FileInf.DateLastModified );
 // Posts the file's last access time to the test log
 Log.Message( FileInf.DateLastAccessed );
 
 // Deletes the file
 FileInf.Delete();
end;

C++Script, C#Script

function GetTimeExample()
{
 var sPath = "C:\\Temp\\TempFile.txt";
 // Creates a file
 aqFile["Create"](sPath);
 
 var FileInf = aqFileSystem.GetFileInfo(sPath);

 // Delays the script execution
 Delay(2000);
 
 // Writes data to the file
 FileInf["WriteToTextFile"]( "Hello, World!", aqFile.ctANSI );
 
 // Delays the script execution
 Delay(2000);
 
 // Reads the file's content
 FileInf["ReadWholeTextFile"]( aqFile.ctANSI );
 
 // Posts the file's creation time to the test log
 Log["Message"]( FileInf["DateCreated"] );
 // Posts the file's last write time to the test log
 Log["Message"]( FileInf["DateLastModified"] );
 // Posts the file's last access time to the test log
 Log["Message"]( FileInf["DateLastAccessed"] );
 
 // Deletes the file
 FileInf["Delete"]();
}

See Also

Working With Files From Scripts
GetFileInfo Method
FindFiles Method
DateCreated Property
DateLastModified Property
GetLastAccessTime Method
SetLastAccessTime Method

Highlight search results