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

前端 未结 2 1503
不知归路
不知归路 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:10

    PST provider locks PST files until the parent process terminates. Even if you close the PST file from Outlook, it will be kept open for 30 minutes for the performance reasons.

    Do you programmatically open the PST file in Outlook?

    0 讨论(0)
  • 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;
    
    0 讨论(0)
提交回复
热议问题