比如,我有这样的一个字符串
String MyFileUrl = "http://www.xx.com/MyFile/123.txt"
String FullName= “文件全名”;//这个如何做?获得的值假设为123.txt
String ExtentName= “扩展名”;//这个又如何做?获得的值伎为txt
在线等待,救命救命!

解决方案 »

  1.   

    string Name=ExtentName.remove(ExtentName.lastIndexof("."),1).toString();
    你在程序里试试,我手写的可能有错,
    就是个字符处理问题。
      

  2.   

    remove后面的那个参数我写错了
    你自己改!
      

  3.   

    好像昨天才写过一个,又练习下了:
    String MyFileUrl = "http://www.xx.com/MyFile/123.txt " ;
    String   FullName=MyFileUrl.Substring(MyFileUrl.LastIndexOf("/")+1,MyFileUrl.Length-MyFileUrl.LastIndexOf("/")-1);
    String   ExtentName=MyFileUrl.Substring(MyFileUrl.LastIndexOf(".")+1,MyFileUrl.Length-MyFileUrl.LastIndexOf(".")-1);
      

  4.   

    string MyFileUr = "http://www.xx.com/MyFile/niub.txt";
    string TmpName =MyFileUr.Substring(MyFileUr.LastIndexOf("/")+1);
    string fileName = TmpName.Substring(0,TmpName.IndexOf("."));
    string TxtName = TmpName.Substring(TmpName.IndexOf("."));
      

  5.   

    我汗,用得着那么麻烦吗,有现成的方法不用
    String MyFileUrl = "http://www.xx.com/MyFile/123.txt ";
    String FullName = System.IO.Path.GetFileName(MyFileUrl);
    String ExtentName = System.IO.Path.GetExtension(MyFileUrl).Trim('.');