当前位置:编程学习 > C#/ASP.NET >>

怎样获取文本里的字符

我要获取文本里的 办公桌_004 而且不固定有多少行


以下几个是要获取的值 请大家帮帮拉


***  lighting psv file output started 2007/03/29 17:41:32  ***
file version:15=000000
file path: C:\Documents and Settings\xx\桌面\建模-1.psv
application: Walkabouter Ver.3.0.2
texture image quality: 60
texture image max size: 256(auto)
geometry precision: 0.007813
view icon: enable
normal vector: disable
color optimize: disable
vertex optimize: enable
parts optimize: enable
--------------------------------------------------------------------------------
 物件编号  识别编号  多边形    共享      形状设定  判断  高精度  名称
--------------------------------------------------------------------------------
        1               306     1:O  丂丂丂丂丂丂             0  外壁/墙面/办公桌_004   
        2               190          丂丂丂丂丂丂             0  外壁/墙面/办公桌_001
        3               306     1:V  丂丂丂丂丂丂             0  外壁/墙面/办公桌_004
        4               346          丂丂丂丂丂丂             0  外壁/墙面/办公桌_005
        5                36          丂丂丂丂丂丂             0  外壁/墙面/办公桌_006
--------------------------------------------------------------------------------
贴图编号  宽  高度  分割  数据大小  压缩率  名称
  
--------------------------------------------------------------------------------
textuer size: 0KB
view icon size: 2KB
geometry size: 36KB
file size: 37KB --------------------编程问答-------------------- up --------------------编程问答-------------------- using System.IO; 

StreamReader vStreamReader = new StreamReader(
    @"C:\你的文件名.txt", Encoding.Default);
string line;
int count = 0;
while ((line = vStreamReader.ReadLine()) != null)
{
    if (line.IndexOf("办公桌_004") >= 0)
        count++;
}
vStreamReader.Close();
--------------------编程问答-------------------- 如果是英文,正则表达式。
学习!+顶 --------------------编程问答-------------------- this.label7.Text = ofd.FileName;
                System.IO.StreamReader reader = new StreamReader(ofd.FileName, System.Text.Encoding.GetEncoding("gb2312"));
                string line;
                string content = "";
                while (reader.Peek() >= 0)
                {
                    line = reader.ReadLine();
                    char[] chr = line.ToCharArray();
                    for (int i = 0; i <chr.Length - 1; i++)
                    {
                        if (chr[i]=='_')
                        {
                            string[] tmp = line.Split('_');
                            content += tmp[1];
                        }
                    }
                        
                }
                textBox5.Text = content; --------------------编程问答-------------------- MSDN STREAMREADER
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,