110,536
社区成员
发帖
与我相关
我的任务
分享
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();
Regex.Replace(yourText,@"\s+","\r\n");