The problem you are having is more related to the overall design of your application. What you described is technically correct, because the proper approach would be to decrypt the files on-the-fly once they are read from their encrypted location.

This way when the data is read from the source file during copying, it's decrypted. Then, when the data is written to the destination, it's encrypted back.

What you would expect to implement is that the code somehow detects that the file being written (remember, there's no "copy" operation in the system, it's just writing of some data) is encrypted. IF writing is done in one thread, then you can inspect the first block of the file, detect the encryption header and stop encryption for this file. The problem, however, is that Windows Explorer in Windows 8 and later copies files in a multithreaded manner and it's possible that you'll get write requests for the logical block 1 before the write request for the logical block 0). In this situation you won't be able to check the data for the encrypted header.

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.