c#操作文本文件问题求助! 请问如何用c#从文本文件中删除一些指定的内容,比如处于/*和*/之间的内容,谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string strText = String.Empty;string strReg = @"\/\*(.|\n|\t| |\r)*?\*\/";using(System.IO.StreamReader reader = System.IO.File.OpenText(@"C:\text.txt")){ strText = reader. ReadToEnd(); System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(strReg, System.Text.RegularExpressions.RegexOptions.Multiline); strText = regex.Replace(strText,String.Empty); }using(System.IO.StreamWriter writer = new System.IO.StreamWriter(@"C:\text.txt")){ writer.Write(strText); writer.Flush(); writer.Close();} 传值调用和传引用调用 C#.NET软件工程的进 插入超过4000个字节时报错。ORA-01036: 非法的变量名/编号 请教大家 C#调用C++ DLL出现的疑难杂症 DataGridViewComboBoxColumns选中的项会自动消失 关于数据库查询。 请问哪里能到得NET里自带控件的原码? 一个dll函数定义的问题,请帮忙解答 频繁的访问数据库,sqlconnection可以一直open不close吗(2) 关于WebService的问题 想用c#做一个winform的发邮件的程序,求点资料,应该引用什么类???在线等 DataGrid问题,求助!winform控件
string strReg = @"\/\*(.|\n|\t| |\r)*?\*\/";
using(System.IO.StreamReader reader = System.IO.File.OpenText(@"C:\text.txt"))
{
strText = reader. ReadToEnd();
System.Text.RegularExpressions.Regex regex
= new System.Text.RegularExpressions.Regex(strReg, System.Text.RegularExpressions.RegexOptions.Multiline); strText = regex.Replace(strText,String.Empty);
}using(System.IO.StreamWriter writer = new System.IO.StreamWriter(@"C:\text.txt"))
{
writer.Write(strText);
writer.Flush();
writer.Close();
}