2013-04-15 2 views
1

у меня есть фрагмент кода, который я пытаюсь исправить:Добавить ввод текстового поля к существующему StartInfo.Arguments

System.Diagnostics.Process p = new System.Diagnostics.Process(); 
p.StartInfo.UseShellExecute = false; 
p.StartInfo.RedirectStandardOutput = true; 
//p.StartInfo.RedirectStandardInput = true; 
p.StartInfo.RedirectStandardError = true; 
p.StartInfo.CreateNoWindow = false; // This line will not create any new window for command prompt. 
p.StartInfo.FileName = @"C:\Program Files (x86)\Citrix\System32\dscheck.exe"; 
p.StartInfo.Arguments = "/full groups /clean"; 
p.StartInfo.Arguments = argTextBox.Text; 
p.Start(); 
System.Threading.Thread.Sleep(50); 
System.Windows.Forms.SendKeys.Send("y"); 
System.Threading.Thread.Sleep(50); 
string s = p.StandardOutput.ReadToEnd(); 
MessageBox.Show(s); //Shows a Popup of the output from Dscheck 
//String s = p.StandardOutput.ReadToEnd(); 

Вот мой вопрос:

p.StartInfo.Arguments = "/full groups /clean"; 
p.StartInfo.Arguments = argTextBox.Text; 

Я пытаюсь передать tscheck.exe /full /groups /clean {UID} - UID введен в argTextBox, но он не работает. Он гласит: p.StartInfo.Arguments = "/full groups /clean"; и берет argTextBox и ничего не кладет.

Любые идеи о том, как добавить ввод текстового поля в существующий аргумент?

ответ

1
p.StartInfo.Arguments = "/full groups /clean " + argTextBox.Text; 

Вместо назначения текста из текстового поля, добавить его к существующим аргументам.

+0

Спасибо, что работал отлично! –

0

Просто добавьте в конце текущих параметров аргументов (с пробелом разделителем конечно)

p.StartInfo.Arguments = "/full groups /clean " + argTextBox.Text; 
    p.Start(); 
0

во втором задании вы заменяете значение, присвоенное, замените эти строки:

p.StartInfo.Arguments = "/full groups /clean"; 
p.StartInfo.Arguments = argTextBox.Text; 

с:

p.StartInfo.Arguments = String.Format("/full groups /clean {0}", argTextBox.Text); 
Смежные вопросы