How to copy a locked file like .pst using delphi xe3

前端 未结 2 1507
不知归路
不知归路 2021-01-28 09:02

I am struggling to find an answer to the following problem. Any and all help would be appreciated.

I am using the following code to try and copy an outlook.pst file whil

2条回答
  •  余生分开走
    2021-01-28 09:16

    Try the fmShareDenyNone flag when creating the TFileStream object:

    stream := TFileStream.Create(filename, fmOpenRead or fmShareDenyNone);
    try 
       slFile.LoadFromStream(stream);
    finally
       stream.Free;
    end;
    

    Function to read the date from a file:

    function GetFileDate(TheFileName: string): string;
    var
      FHandle: integer;
    begin
      FHandle := FileOpen(TheFileName, fmShareDenyNone);
      try
        Result := DateTimeToStr(FileDateToDateTime(FileGetDate(FHandle)));
      finally
        FileClose(FHandle);
      end;
    end;
    

提交回复
热议问题