去除换行符

一般处理可以使用 Replace("\r\n", ""); 来替换

 

如果文件路径带换行符的会错误(路径中有非法字符或者系统找不到文件)

11557125

string s = @"C:\Windows\System32\cmd.exe" + "\r\n"; 
richTextBox1.LoadFile(s);

 

 

11640812

 

string s = @"C:\Windows\System32\cmd.exe" + "\n"; 
System.Diagnostics.Process.Start(s);

 

替换\r

textBox1.Text =textBox1.Text.Replace("\r", "");

替换 \n

textBox1.Text =textBox1.Text.Replace("\n", "");
posted @ 2013-11-23 11:43  XE2011  阅读(215)  评论(0编辑  收藏  举报