大神请进来指教指教。.net C# .txt的读取 textboxC#.net.txt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 StreamReader sr = new StreamReader("test.txt"); string line; while ((line = sr.ReadLine())!= null) { if (line.IndexOf("span") != -1) { string s = line.Split('>')[1]; s = s.Split('<')[0]; textBox.text = s; break; } } static void Main(string[] args) { string txt = File.ReadAllText("test.txt",Encoding.Default); string reg = @"<span>(.+?)</span>"; MatchCollection mc = Regex.Matches(txt, reg); StringBuilder sb = new StringBuilder(); foreach (Match item in mc) { sb.Append(item.Groups[1]); } Console.WriteLine(sb.ToString()); Console.ReadKey(); }正则表达式更好一些 NPOI操作office 用SqlCommandBuilder方法保存数据集中的数据 存储过程不能将参数传入进去C#。 [求助]请教各位一下wap网站登录模式 多层控件命名 关于stream流 关于DataGrid主从表的问题 程序运行过程中出现这个提示,然后就退出了,怎么回事啊?? 怎样使用mciSendCommand函数播放视频? 用ShowDialog出现的问题,同窗体使用快键的问题 C# dispose释放资源问题 请教一个关于以一个List集合为类属性时,get、set设置问题
StreamReader sr = new StreamReader("test.txt");
string line;
while ((line = sr.ReadLine())!= null)
{
if (line.IndexOf("span") != -1)
{
string s = line.Split('>')[1];
s = s.Split('<')[0];
textBox.text = s;
break;
}
}
{
string txt = File.ReadAllText("test.txt",Encoding.Default);
string reg = @"<span>(.+?)</span>";
MatchCollection mc = Regex.Matches(txt, reg);
StringBuilder sb = new StringBuilder();
foreach (Match item in mc)
{
sb.Append(item.Groups[1]);
}
Console.WriteLine(sb.ToString());
Console.ReadKey();
}
正则表达式更好一些