aqFile.GetCreationTime Method

Applies to TestComplete 14.72, last modified on December 24, 2020

Description

Use the GetCreationTime method to determine the time the file was created. To assign a new date and/or time of creation, use the SetCreationTime method.

Declaration

aqFile.GetCreationTime(PathToFile)

PathToFile [in]    Required    String    
Result Date/Time

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

PathToFile

Specifies the fully-qualified path to the desired file.

Result Value

A Date object that stores the file's creation date.

Example

The code below creates a file, writes some data to it and reads the file 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);
 
 // Retards script execution
 Delay(2000);
 
 // Writes data to the file
 aqFile.WriteToTextFile(sPath, "Hello, World!", aqFile.ctANSI, false);
 
 // Retards script execution
 Delay(2000);
 
 // Reads file content
 aqFile.ReadWholeTextFile(sPath, aqFile.ctANSI);
 
 // Posts file creation time to the test log
 Log.Message(aqFile.GetCreationTime(sPath));
 // Posts file last write time to the test log
 Log.Message(aqFile.GetLastWriteTime(sPath));
 // Posts file last access time to the test log
 Log.Message(aqFile.GetLastAccessTime(sPath));
 
 // Deletes the file
 aqFile.Delete(sPath);
}

Python

def GetTimeExample():
  sPath = "C:\\Temp\\TempFile.txt"
  # Creates a file
  aqFile.Create(sPath)
  # Retards script execution
  Delay(2000);
  
  # Writes data to the file
  aqFile.WriteToTextFile(sPath, "Hello, World!", aqFile.ctANSI, False)
  # Retards script execution
  Delay(2000);
  
  # Reads file content
  aqFile.ReadWholeTextFile(sPath, aqFile.ctANSI)
  
  # Posts file creation time to the test log
  Log.Message(aqFile.GetCreationTime(sPath))
  # Posts file last write time to the test log
  Log.Message(aqFile.GetLastWriteTime(sPath))
  # Posts file last access time to the test log
  Log.Message(aqFile.GetLastAccessTime(sPath))
  
  # Deletes the file
  aqFile.Delete(sPath)

VBScript

Sub GetTimeExample

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

 ' Creates a file
 Call aqFile.Create(sPath)
 
 ' Retards script execution
 Call Delay(2000)
 
 ' Writes data to the file
 Call aqFile.WriteToTextFile(sPath, "Hello, World!", aqFile.ctANSI, false)
 
 ' Retards script execution
 Call Delay(2000)
 
 ' Reads file content
 Call aqFile.ReadWholeTextFile(sPath, aqFile.ctANSI)
 
 ' Posts file creation time to the test log
 Call Log.Message(aqFile.GetCreationTime(sPath))
 ' Posts file last write time to the test log
 Call Log.Message(aqFile.GetLastWriteTime(sPath))
 ' Posts file last access time to the test log
 Call Log.Message(aqFile.GetLastAccessTime(sPath))
 
 ' Deletes the file
 Call aqFile.Delete(sPath)
End Sub

DelphiScript

function GetTimeExample;
 var sPath;

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

 // Creates a file
 aqFile.Create(sPath);
 
 // Retards script execution
 Delay(2000);
 
 // Writes data to the file
 aqFile.WriteToTextFile(sPath, 'Hello, World!', aqFile.ctANSI, false);
 
 // Retards script execution
 Delay(2000);
 
 // Reads file content
 aqFile.ReadWholeTextFile(sPath, aqFile.ctANSI);
 
 // Posts file creation time to the test log
 Log.Message(aqFile.GetCreationTime(sPath));
 // Posts file last write time to the test log
 Log.Message(aqFile.GetLastWriteTime(sPath));
 // Posts file last access time to the test log
 Log.Message(aqFile.GetLastAccessTime(sPath));
 
 // Deletes the file
 aqFile.Delete(sPath);
end;

C++Script, C#Script

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

 // Creates a file
 aqFile["Create"](sPath);
 
 // Retards script execution
 Delay(2000);
 
 // Writes data to the file
 aqFile["WriteToTextFile"]( sPath, "Hello, World!", aqFile.ctANSI, false );
 
 // Retards script execution
 Delay(2000);
 
 // Reads file content
 aqFile["ReadWholeTextFile"]( sPath, aqFile.ctANSI );
 
 // Posts file creation time to the test log
 Log["Message"]( aqFile["GetCreationTime"](sPath) );
 // Posts file last write time to the test log
 Log["Message"]( aqFile["GetLastWriteTime"](sPath) );
 // Posts file last access time to the test log
 Log["Message"]( aqFile["GetLastAccessTime"](sPath) );
 
 // Deletes the file
 aqFile["Delete"](sPath);
}

See Also

Working With Files From Scripts
GetLastAccessTime Method
GetLastWriteTime Method
SetCreationTime Method
DateCreated Property

Highlight search results