IDocument.CreationDate

Syntax

CreationDate: DateTime;

Description

The CreationDate property determines the creation date for the file stored in the document.

Comments

Creation date of the loaded file is set in this property during loading the document from the file. The current date and time are set in the CreationDate property during loading the document from the stream. On loading new versions of the file, the property value is automatically updated.

Example

Sub CompareDocument(Doc: IDocument);
Var
    FName: String;
    FInfo: IFileInfo;
Begin
    FName := Doc.FileName;
    If File.Exists(FName) Then
        FInfo := New FileInfo.Attach(FName);
        //If the file on the disk differs from that saved in the document, then
        //load a new version to the document
        If (Doc.CreationDate <> FInfo.CreationTime) Or
            (Doc.ModificDate <> FInfo.LastWriteTime) Or
            (Doc.Size <> FInfo.Size) Then
            Doc := (Doc As IMetabaseObject).Edit As IDocument;
            Doc.LoadFromFile(FName);
            (Doc As IMetabaseObject).Save;
        End If
    Else
        //If the file does not exist, unload it from the document
        Doc.SaveToFile(FName);
    End If;
End Sub CompareDocument;

The given procedure compares information about the file on the disk and information saved in the document. If there are differences in information, the latest version of the file is loaded to the document.

See also:

IDocument