And you thought it couldn’t be done: copying locked files, such as your .pst file from Outlook, while Outlook has a lock on it. Enter the Volume Shadow Copy Provider.
On Windows XP and Windows Server 2003 a new service is available for your comfort: the Volume Shadow Copy Service. The idea is that you can temporarily mount a volume that provides a shadow copy of another drive. This shadow copy doesn’t have the locks that might exist on files on the original volume.
There are several COM interfaces that you can use to leverage the functionality, such as IVSSAdmin. There is even a COM+ application MS Software Shadow Copy Provider. And to top it off there is an SDK available for download. The SDK includes a sample project for vshadow.exe. It is a command-line tool, that when combined with some smart DOS commands in a batch file, can copy a file that is locked.
I will try to get some COM Interop going to make this all available through the VSS.VSSCoordinator or VSSW.VSSoftwareProvider class. If you beat me to it, let me know. 😉