本帖最后由 lcmlhs_2005 于 2010-09-18 11:25:56 编辑

解决方案 »

  1.   

    string str="目标串";
    string txt=文本;string reslute=txt.substring(txt.insideof(str),10);
    console.write(reslute);
      

  2.   

    用正则表达式匹配,然后用SubString
    var rg = new Regex("你的Pattern");
    var match = rg.Match("你的文本");
    var matchText = match.Group[0].Value; //你找到的字符串
    var lastTen = matchText.Substring(matchText.Length - 10);
    结束。
      

  3.   

    str的内容怎样从文本里得来呢,要知道我的文本几十兆大小的
      

  4.   

    Regex reg=new Regex("查找的条件(?<str>.{10})");
    MatchCollection mac=reg.matches(文本);
    foreach(match m in mac)
    {
    console.write(m.groups["str"].value);
    }
      

  5.   

    FileStream fs = File.OpenRead("你的文件");
    if (fs.Length < 10)
    {
        fs.Close();
        return;
    }
    fs.Seek(-10, SeekOrigin.End);
    byte[] buf = new byte[10];
    fs.Read(buf, 0, 10);
    //Encoding.GetEncoding("gb2312")根据你实际的修改
    string result = Encoding.GetEncoding("gb2312").GetString(buf);//result就是你要的
    fs.Close();
      

  6.   

    楼上的领会错了,我是说找到字符串后,在该字符串后面截取十个字符的。比如:要找的是字符串是“abc”,如果在文本文件里找到了“abc”字符串,那么就在它后面,即c后面的第一个字符开始,截取10个字符的!!!