I have a button, and I use Process.Start when clicking it, although I select data from textBox1.Text.
Although this data on textBox1.Text does not come out properly if there are spaces in textBox1.Text
eg textBox1.Text = testing_123 works
although textBox1.Text = testing 1 2 3 doesn't work (it will only include "testing")
The code is below:
private void button19_Click(object sender, EventArgs e)
{
Process.Start("test.exe", textBox1.Text);
}
Simply quote the args like this before passing:
private void button19_Click(object sender, EventArgs e)
{
Process.Start("test.exe", "\"" + textBox1.Text + "\"");
}
在参数字符串周围添加引号。
If you just want to get rid of the spaces:
TextBox1.Text.Replace(" ",string.Empty)
Or if you want to substitute another character (underscore) then try:
TextBox1.Text.Replace(" ","_")
If you want to include the space then @Teoman has your answer...
It depends on what you mean by " handle ".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.