I am trying to create a test harness, which tests CopyFileEx from kernel32.dll for copying files across the WAN.
My code is based upon on a link found on here
What I have done is create a shared folder on my C:\ using netapi and placed inside the folder a test file. Then I created a thread to call my CopyFileEx and using the main thread in my Console Application I disconnect my share folder after 1 second. The purpose of this is test my code when COPY_FILE_RESTARTABLE is called in CopyFileEx once the share folder is reconnected and the copying continues.
The problem is when I add to the delegate (CopyProgressHandler), a streamwriter to write the bytes to a text file, it throws an exception that the file is being used by another process.
So, my question is how can record the number of bytes that have been written when CopyFileEx has been called to a text file when I have it running under its own thread?
In essence I need to record the number of bytes written when a share is removed and reintroduced. Also is it possible to record the point when copying has been interrupted?