Copy a File that is in use/locked by another program
Posted on 2004-04-11
I want to know if there is a method, with delphi, to copy a file that is in use/locked by another application: I can make some examples:
I've tried to copy some types of locked files, like:
1. A Microsoft Access .mdb file opened by access with exclusive access
2. Some .aspx, .dll files of an opened Visual Studio.net solution
3. The Outlook.pst file while Microsoft Outlook is opened
I've tried with the following methods:
1. Using Windows API function (ShellOp)
2. Using CopyFile e CopyFileW functions
3. Using FileStream, MemoryStream, FileBlock, FileSeek Methods
4. Using Assign File Method
None of theese methods has worked with the Outlook.pst file.
The windows API funtion works for all, but not for Outlook.pst, but has a very bad issue: it prompts the user if there is an error or a overwrite conflict (also if I've set the right flags for NO ERROR UI and NO PROMPTS/NI CONFIRMATION).
The only method for copy the Outlook.pst file is to open it with the notepad (it works !) and then save the file to another location (!?). So copy that file is possible! How with delphi ? (I can accept also a c++ solution, i could make an external .dll)