如何使用delphi xe3复制一个类似.pst的锁定文件 [英] How to copy a locked file like .pst using delphi xe3

查看:190
本文介绍了如何使用delphi xe3复制一个类似.pst的锁定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力寻找以下问题的答案。任何和所有的帮助将不胜感激。



在outlook打开的时候,我正在使用以下代码来尝试复制outlook.pst文件。我不能让它成功。
它不给出错误,它只是不复制文件。

  copyfile('C:\Users \Administrator\Documents\Outlook Files\Outlook.pst','F:\Outlook.pst'); 

如果你们知道我将如何复制这样的锁定文件,请协助。 p>

我已经尝试发现,TFilestream也不起作用。



这2个是我知道的唯一选项。任何帮助将不胜感激。



谢谢



我已经尝试了以下代码,并得到一个错误,说文件是在另一个进程中使用(outlook)。

  procedure TForm1.Button2Click(Sender:TObject); 
var
NewFileName:string;
NewFile:TFileStream;
OldFile:TFileStream;
开始
NewFileName:='F:\outlook.pst';
OldFile:= TFileStream.Create('C:\Users\Administrator\Documents\Outlook Files\outlook.pst',fmOpenRead或fmShareDenyWrite);
try
NewFile:= TFileStream.Create(NewFileName,fmCreate或fmShareDenyNone);
try
NewFile.CopyFrom(OldFile,OldFile.Size);
finally
FreeAndNil(NewFile);
结束
finally
FreeAndNil(OldFile);
结束
结束

请参阅以下链接。如果有人可以转换代码。问题应该解决。
如何使用c#打开pst文件时复制pst文件

解决方案

PST提供程序锁定PST文件,直到父进程终止。即使您从Outlook关闭PST文件,由于性能原因,它将保持打开30分钟。



您是否以编程方式在Outlook中打开PST文件? p>

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 while outlook is open. And i cannot get it to succeed. It does not give an error, it just doesnt copy the file.

copyfile('C:\Users\Administrator\Documents\Outlook Files\Outlook.pst','F:\Outlook.pst');

If you guys know how i will be able to copy a locked file like that please assist.

I have tried and found that TFilestream also does not work.

And those 2 are the only options i know off. any help would be greatly appreciated.

Thank You

I have tried the following code as-well and get an error saying that the file is in use from another process(outlook).

procedure TForm1.Button2Click(Sender: TObject);
var
   NewFileName: string;
   NewFile: TFileStream;
   OldFile: TFileStream;
Begin
           NewFileName:='F:\outlook.pst';
           OldFile := TFileStream.Create('C:\Users\Administrator\Documents\Outlook Files\outlook.pst', fmOpenRead or fmShareDenyWrite);
            try
              NewFile := TFileStream.Create(NewFileName, fmCreate or fmShareDenyNone);
              try
                NewFile.CopyFrom(OldFile, OldFile.Size);
              finally
                FreeAndNil(NewFile);
              end;
            finally
              FreeAndNil(OldFile);
            end;
end;

Please see the following link. If anybody can convert the code. the problem should be solved. How to copy a pst file while it is open using c#

解决方案

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?

这篇关于如何使用delphi xe3复制一个类似.pst的锁定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆