FileSource = "H:\\资料\\库\\哲学名字术语2.txt"
从这个串截取“哲学名字术语”几个字符,就是"\\" 和“.”之间的字符。

解决方案 »

  1.   

    LastIndexOf(".")
    LastIndexOf("\\")
      

  2.   

    try
    string FileSource = "H:\\资料\\库\\哲学名字术语2.txt";
    string resultStr = "";
    Match m = Regex.Match(FileSource, @"(?<=\\)[^\\]*?(?=\.)");
    if(m.Success)
    {
        resultStr = m.Value;
    }
      

  3.   

    or trystring FileSource = "H:\\资料\\库\\哲学名字术语2.txt";
    string resultStr = FileSource.Substring(FileSource.LastIndexOf("\\")+1,FileSource.LastIndexOf(".")-FileSource.LastIndexOf("\\")-1);
      

  4.   

    System.Io.Path.GetFileNameWithoutExtension(FileSource)
      

  5.   

    System.IO.Path.GetFileNameWithoutExtension(FileSource)
      

  6.   

    FileSource.substring(FileSource.lastIndexOf("\\"));
    FileSource.substring(1,FileSource.lastIndexOf(".")-1);
    验证过了啊