C# 在cmd中运行命令

C# 在cmd中运行命令,c#,wpf,C#,Wpf,我有这个代码,我正在尝试运行cmd命令 点击按钮事件: private void _ddlbtn_Click(object sender, RoutedEventArgs e) { string ftype = _ftBox.Text; /// define the file type desired from _ftBox textbox string url = _urlBox.Text; /// define the url to download. from _urlBo

我有这个代码,我正在尝试运行
cmd
命令 点击按钮事件:

private void _ddlbtn_Click(object sender, RoutedEventArgs e)
{
    string ftype = _ftBox.Text; /// define the file type desired from _ftBox textbox
    string url = _urlBox.Text; /// define the url to download. from _urlBox textbox
    string upat = _pathlbl.Content.ToString(); /// define the path to save to from the the pre set path string
    string ucmd = "wget -r -P "+upat+" -A."+ftype+" --no-parent "+url;
    Process.Start("cmd.exe",ucmd); /// open cmd and run the command from the ucmd string

}
cmd
窗口打开,但字符串不会通过

如果重要的话,我会使用Visual Studio 2013


有什么想法吗?

当cmd窗口打开时,它会在默认目录或工作目录中打开

DOS不知道wget。您需要给它一个绝对路径,或者将信息放入path环境变量中

    private void _ddlbtn_Click(object sender, RoutedEventArgs e)
{
    string ftype = _ftBox.Text;  /// define file extension from filetype textbox
    string url = _urlBox.Text;  /// declare the url from text box
    string upat = _pathlbl.Content.ToString(); /// define the download to location
    string ucmd = "-r -P "+upat+" -A."+ftype+" --no-parent "+url; /// define full string to cmd arguments
    Process.Start("wget.exe",ucmd);
}

这对我来说很管用

什么是“绳子不会通过”呢?也许您应该考虑一些空格?这不是
cmd.exe
的合适命令行。它至少应该以
/C
/K
开头。为什么要使用CMD.exe运行wget?你为什么不直接给wget打电话?为什么要用另一层把它复杂化?再说一次,当C#有自己的第一类等价物时,为什么要使用wget?我试图将其传递到cmd窗口:string ucmd=“wget-r-P”+upat+-A.“+ftype+”--no parent”+urlwell mason老实说,我认为我不能单独运行wget。但我肯定会尝试,这与我的问题无关。cmd窗口打开,但没有任何内容。它只是等待输入,我可以键入命令并使用它,但我希望在那里运行的命令没有通过