# VBForums CodeBank > CodeBank - Other >  [DELPHI] - File Last Modified

## Madboy

```
function GetFileModifyDate(FileName: string): TDateTime;
var
  h: THandle;
  Struct: TOFSTRUCT;
  lastwrite: Integer;
  t: TDateTime;
begin
  h := OpenFile(PChar(FileName), Struct, OF_SHARE_DENY_NONE);
  try
    if h <> HFILE_ERROR then
    begin
      lastwrite := FileGetDate(h);
      Result    := FileDateToDateTime(lastwrite);
    end;
  finally
    CloseHandle(h);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Opendialog1.Execute then
    label1.Caption := FormatDateTime('dddd, d. mmmm yyyy hh:mm:ss',
      GetFileModifyDate(Opendialog1.FileName));
end;
```

----------

