Example #1
0
 private void CopyTargets()
 {
     MessageBar.Locked = true;
     foreach (var target in targets)
     {
         string oldPath = target.OldFilePath;
         string newPath = target.NewFilePath;
         if (File.Exists(oldPath))
         {
             if (oldPath.Equals(newPath, StringComparison.OrdinalIgnoreCase))
             {
                 // name casing changed
                 // we cannot append to the extension, as it will break finding possibly needed references
                 // we don't use folders to avoid several possible problems and ease some logic
                 newPath = target.TmpFilePath = Path.Combine(Path.GetDirectoryName(oldPath),
                                                             Path.GetFileNameWithoutExtension(oldPath) +
                                                             "$renaming$" +
                                                             Path.GetExtension(oldPath));
             }
             if (!Path.IsPathRooted(newPath))
             {
                 newPath = Path.Combine(Path.GetDirectoryName(oldPath), newPath);
             }
             string newDirectory = Path.GetDirectoryName(newPath);
             if (!Directory.Exists(newDirectory))
             {
                 Directory.CreateDirectory(newDirectory);
             }
             RefactoringHelper.Copy(oldPath, newPath, true, true);
         }
     }
     MessageBar.Locked = false;
 }