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

大城市里の小女人 提交于 2019-12-02 11:23:54

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?

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;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!