作者bero (bero)
看板C_Sharp
標題Re: [問題] 逸散字元是否能夠不用呢?
時間Sun Dec 20 01:20:29 2009
部分原始碼:
private void button1_Click_1(object sender, EventArgs e)
{
Process.Start("C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\
powershell.exe", test.Text);
}
test為richtextbox
內容為
@"
function aa{
"hello world"
}
aa
read-host
"
hello world兩邊的"如果不改成\"
那powershell就會跑失敗...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.73.237.242
推 kyoin:要改成這樣 ""hello world"" 12/20 01:26
→ bero:可是這樣就要動到我原本的script檔呀...希望可以完全不用改 12/20 01:32
→ bero:畢竟改\"跟改""對於後續要修改script都會造成一定程度的障礙 12/20 01:34
推 kyoin:請問一下你在Button_click得到的test.text是你自己輸入在 12/20 01:47
→ kyoin:richtextbox的值嗎? 12/20 01:48
→ bero:是的...是在visual studio裡面打的,不是編譯好執行時打的 12/20 15:42
推 evirtues:試試test.Text.Replace("\"", "\\\"") 12/20 22:09