如何解决String分为3行。 [英] how to solve String spliting into 3 lines.
本文介绍了如何解决String分为3行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的程序中,我想创建一个批处理文件,字符串必须显示在一行中,但是当我执行我的程序时,它会自动分成3行。我不知道怎么解决它。
In my programe i want to create a batch file and the string has to be displayed in a single line but when i execute my program it automatically splits into 3 lines. I dont knwo how to solve it.
private void BtnCreate_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
StreamWriter file = new StreamWriter("Export.bat");
file.WriteLine("c: ");
file.WriteLine("cd \\");
file.WriteLine("cd Program Files ");
file.WriteLine("cd VMware");
file.WriteLine("cd VMware OVF Tool");
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
sName = row.Cells[0].Value.ToString();
sPath = row.Cells[1].Value.ToString();
//richTextBox1.Text = richTextBox1.Text + Environment.NewLine + sName;
file.WriteLine("start ovftool.exe --powerOffSource vi://" + TxtUsername.Text + ":" + TxtPassword.Text + "@"
+ TxtIP.Text + sPath + " " + "\"" + TxtBrowsepath.Text + "\\" + sName + "\\"
+ sName + ".ovf" + "\"" + Environment.NewLine);
//Console.WriteLine("sName: " + sName + "sPath: " + sPath);
}
file.WriteLine("pause");
MessageBox.Show("Batch File Created","Batch File");
file.Close();
}
输出:
Out put:
c:
cd \
cd Program Files
cd VMware
cd VMware OVF Tool
start ovftool.exe --powerOffSource vi://izaz:pa55word@192.168.123.195/UView-Web_Cardio_2015_v2 "C:\Users\demo\Desktop\
UView-Web_Cardio_2015_v2\
UView-Web_Cardio_2015_v2.ovf"
start ovftool.exe --powerOffSource vi://izaz:pa55word@192.168.123.195/asd/UV_CARDIO "C:\Users\demo\Desktop\
UV_CARDIO\
UV_CARDIO.ovf"
start ovftool.exe --powerOffSource vi://izaz:pa55word@192.168.123.195/vbnrt735w6%5c/MUSE_DEMO "C:\Users\demo\Desktop\
MUSE_DEMO\
MUSE_DEMO.ovf"
start ovftool.exe --powerOffSource vi://izaz:pa55word@192.168.123.195/4564/DEMO-EA "C:\Users\demo\Desktop\
DEMO-EA\
DEMO-EA.ovf"
start ovftool.exe --powerOffSource vi://izaz:pa55word@192.168.123.195/CCW5.1.1_DEMO "C:\Users\demo\Desktop\
CCW5.1.1_DEMO\
CCW5.1.1_DEMO.ovf"
start ovftool.exe --powerOffSource vi://izaz:pa55word@192.168.123.195/vbnrt735w6%5c/sdfasd34564/AWServer_3.1 "C:\Users\demo\Desktop\AWServer_3.1\AWServer_3.1.ovf"
pause
推荐答案
你需要用引号括起路径,因为它里面有空格。
cd VMware OVF工具
mea ns它将移动到目录VMware并且还提供参数OVF和Tool(可能给出错误)
它应该是cdVMware OVF Tool
您可以通过转义它们来添加c#中的引号,例如:this \是一个引用。
祝你好运!
You need to surround the path with quotes because it has spaces in it.
cd VMware OVF Tool
means it will move into directory VMware and also gives the parameters OVF and Tool (probably giving an error)
It should becd "VMware OVF Tool"
You can add quotes in c# by escaping them, like:"this \" is a quote."
Good luck!
这篇关于如何解决String分为3行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文