日期:2014-05-17 浏览次数:20892 次
Regex.Replace(yourText,@"\s+","\r\n");
------解决方案--------------------
System.IO.FileStream streamTxt = new System.IO.FileStream(AppDomain.CurrentDomain.BaseDirectory+"test.txt", System.IO.FileMode.Open); byte[] bytesTxt = new byte[streamTxt.Length]; streamTxt.Read(bytesTxt, 0, bytesTxt.Length); string strTxt = System.Text.Encoding.Default.GetString(bytesTxt); strTxt=System.Text.RegularExpressions.Regex.Replace(strTxt, @"\s+", "\r\n"); streamTxt.SetLength(0); streamTxt.Write(System.Text.Encoding.Default.GetBytes(strTxt), 0, System.Text.Encoding.Default.GetBytes(strTxt).Length); streamTxt.Close();