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#