Exemplo n.º 1
0
 static void Main(string[] args)
 {
     if (args.Length < 3)
     {
         Console.WriteLine(Usage());
         return;
     }
     var inputDir = _GetDirectoryInfo(args[0]);
     var outputDir = _GetDirectoryInfo(args[1]);
     var option = args[2].ToLower();
     if (option != "a" && option != "o")
     {
       Console.WriteLine(Usage());
       return;
     }
     var robo = new Robo();
     switch (option)
     {
         case "a":
         robo.Switches = robo.DefaultSwitches;
           break;
         case "o":
           robo.Switches = "/mir /tee /v /w:5 /r:5";
           break;
         default:
           Console.WriteLine("Unknown option: '{0}'", option);
           break;
     }
     bool createNewFolderInDest = false;
     if (args.Length > 3 && !String.IsNullOrEmpty(args[3]) && args[3].ToLower() == "c")
       createNewFolderInDest = true;
     Console.WriteLine(robo.GenerateRobocopyCommand(inputDir, outputDir, createNewFolderInDest));
 }
Exemplo n.º 2
0
        private void btnRobocopy_Click(object sender, EventArgs e)
        {
            var srcDirsList = GetSrcDirList(false);
              if (srcDirsList.Count < 1 || SelectedDrive == null)
              {
            _PrintOutput("Need to select folder(s) in left pane and one folder in right pane");
            return;
              }

              if (!cbCreateOnCopy.Checked && srcDirsList.Count > 1)
              {
            _PrintOutput("Cannot copy multiple source folders to single destination folder");
            return;
              }

              _PrintOutput(":: Determining total size to copy.  Please wait.");
              var totalBytesToCopy = GetTotalSizeOfSrcDirs();
              if (SelectedDrive.FreeSpace < totalBytesToCopy)
              {
            _PrintOutput(String.Format(":: WARNING! Total size to copy exceeds free space{0}size:{1}{2}free:{3}"
              , Environment.NewLine
              , SelectedDrive.FreeSpace
              , Environment.NewLine
              , totalBytesToCopy));
              }
              else
              {
            _PrintOutput(String.Format(":: total to copy: {0}, space free: {1}{2}"
              , totalBytesToCopy, SelectedDrive.FreeSpace
              , Environment.NewLine));
              }

              var selectedNode = tvwDest.SelectedNode;

              var destDirInfo = GetSelectedDestDir(selectedNode);
              if (destDirInfo == null)
              {
            return;
              }

              var robo = new Robo();
              switch (cbMirror.Checked)
              {
            case false:
              robo.Switches = robo.DefaultSwitches;
              break;
            case true:
              robo.Switches = "/mir /tee /v /w:5 /r:5";
              break;
            default:
              Console.WriteLine("Unknown option");
              break;
              }

              foreach (var dirPath in srcDirsList)
              {
            _PrintOutput(robo.GenerateRobocopyCommand(
                new DirectoryInfo(dirPath)
              , destDirInfo
              , cbCreateOnCopy.Checked));
              }
        }