DateLastModified Property

Applies to TestComplete 14.0, last modified on January 23, 2019

Description

Use the DateLastModified property to learn when the corresponding file was last modified.

Declaration

aqFileInfoObj.DateLastModified

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

A Date object that stores the date the file was last modified.

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
aqFileSystem.GetFileInfo Method
aqFileSystem.FindFiles Method
DateCreated Property
DateLastAccessed Property
aqFile.GetLastWriteTime Method
aqFile.SetLastWriteTime Method

Highlight search results