Ejemplo n.º 1
0
 private void CopyFolder(string sourcePath, string destinationPath, bool overwriteIfDifferent, OnStateChangedDelegtae onStateChanged)
 {
     string[] directories = Directory.GetDirectories(sourcePath);
     string[] files       = Directory.GetFiles(sourcePath);
     if (!Directory.Exists(destinationPath))
     {
         this._fileManager.CreateDirectory(destinationPath);
     }
     foreach (string str in directories)
     {
         string path2 = Path.Combine(destinationPath, new DirectoryInfo(str).Name);
         this.CopyFolder(str, Path.Combine(destinationPath, path2), overwriteIfDifferent, onStateChanged);
     }
     foreach (string str1 in files)
     {
         FileInfo fileInfo1 = new FileInfo(str1)
         {
             IsReadOnly = false
         };
         onStateChanged(string.Format("Copying {0} - {1}/{2}", (object)fileInfo1.Name, (object)this._stepIndex, (object)this._stepCount));
         string str2 = Path.Combine(destinationPath, fileInfo1.Name);
         if (overwriteIfDifferent && System.IO.File.Exists(str2))
         {
             FileInfo fileInfo2 = new FileInfo(str2);
             if (fileInfo2.LastWriteTime != fileInfo1.LastWriteTime || fileInfo2.Length != fileInfo1.Length)
             {
                 this._fileManager.Copy(str1, str2, true);
             }
             else
             {
                 this._stepIndex = this._stepIndex + 1;
             }
         }
         else
         {
             this._fileManager.Copy(str1, str2, true);
         }
     }
 }
Ejemplo n.º 2
0
 public void Copy(string sourcePath, string destinationPath, int stepIndex, int stepCount, OnStateChangedDelegtae onStateChanged, bool overwriteIfDifferent)
 {
     this._stepCount = stepCount;
     this._stepIndex = stepIndex;
     this.CopyFolder(sourcePath, destinationPath, overwriteIfDifferent, onStateChanged);
     stepIndex = this._stepIndex;
 }