public void FinishCopy(string destFile, TimeSpan timeout, CopyReaderDelegate reader)
            {
                // OK, file copy has begun, now try loading.
                bool success = false;
                var sw = Stopwatch.StartNew();
                do
                {
                    // Yes, not ideal - should be waiting on the file itself.
                    try
                    {

                        Debug.WriteLine(string.Format("Trying to open {0}", destFile));
                        using (var f = File.Open(destFile, FileMode.Open, FileAccess.Read, FileShare.None))
                        {
                            // OK, we have the file open. Call the delegate!
                            success = true;
                            reader(f);
                        }
                    }
                    catch (System.IO.FileNotFoundException)
                    {
                        SleepToRetry(); // too early!
                    }
                } while (!success && sw.Elapsed < timeout);

                if (!success)
                {
                    throw new TimeoutException(string.Format("Timeout waiting for {0} to be exclusively readable.", destFile));
                }
            }
            public void Perform(Shell32InstanceWrapper shell, string destDir, Shell32.FolderItem src, TimeSpan timeout, CopyReaderDelegate reader)
            {
                var destFile = Path.GetFullPath(Path.Combine(destDir, Path.GetFileName(src.Path)));

                var destFolder = shell.NameSpace(destDir);
                StartCopy(src, destFolder);
                FinishCopy(destFile, timeout, reader);
            }
 public static void CopyItemHereAndRead(Shell32InstanceWrapper shell, string destDir, Shell32.FolderItem src, TimeSpan timeout, CopyReaderDelegate reader)
 {
     var performer = new CopyPerformer();
     performer.Perform(shell, destDir, src, timeout, reader);
 }