尝试为Robocopy编写一个简单的GUI [英] Trying to write a simple GUI for Robocopy

查看:93
本文介绍了尝试为Robocopy编写一个简单的GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试为Robocopy编写一个简单的GUI.在下面的代码中,我可以使CMD窗口出现-非常简短...然后消失-本质上,我认为我的代码在正常工作",除了没有传递我的变量和/或争论. >
非常感谢您的帮助-谢谢-Scott

Hi there, I am trying to write a simple GUI for Robocopy. In the code below I can get the CMD window to appear - very briefly ... then disappear -- essentially I think my code is "working" except it''s not getting my variables passed and/ or the arguements.

Help is most appreciated -- Thanks -- Scott

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Robocopy : Form
    {
        public Robocopy()
        {
            InitializeComponent();
            
        }
        private void Srcbutton_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.ShowDialog();
        }
        private void Destbutton_Click(object sender, EventArgs e)
        {
            folderBrowserDialog2.ShowDialog();
        }
        private void Cpybutton_Click(object sender, EventArgs e)
        {
            string SrcFold = folderBrowserDialog1.SelectedPath;
            string DestFold = folderBrowserDialog2.SelectedPath;
            string args = "\"" + SrcFold + "\" " + DestFold + "\" /E /COPY:dat";
            ProcessStartInfo StartInfo = new ProcessStartInfo
            {
                WorkingDirectory = @"C:\RoboCopy_IT_Folder",
                Arguments = "args",
                FileName = @"C:\Windows\System32\robocopy.exe",
                RedirectStandardError = true,
                RedirectStandardOutput = true,
                WindowStyle = ProcessWindowStyle.Normal,
                UseShellExecute = false
            };
            Process NewProcess = new Process();
            NewProcess.StartInfo = StartInfo;
            if (NewProcess.Start())
            {
                NewProcess.WaitForExit();
                //ProcessOutput.Text = NewProcess.StandardOutput.ReadToEnd();                
            }
        }       
    }
}

推荐答案

我认为这行的操作数
I think the operand of this line
Arguments = "args";


不应使用双引号字符.您要将args的内容发送到新进程.


should not have the double quote characters. You want to send the contents of args to the new process.


这篇关于尝试为Robocopy编写一个简单的GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆