截取字符串的一些方法

        string strFileName = “aaa/bbb/ccc.html”

方法一:

        string[] strSplit = strFileName.Split(new char[] { '.' });
        string strUrl = strSplit[0].ToString();          //aaa/bbb/ccc
        string strName = strSplit[1].ToString();      //html

 

方法二:
        string strName = strFileName.Substring(strFileName.LastIndexOf("/") + 1);

        string[] strSplit = strFileName.Split(new char[] { '/' });
        string strUrl = "" ;
        if (strSplit.Length > 1)
        {
            strUrl = strFileName.Substring(0, strFileName.LastIndexOf("/"));
        }

posted on 2010-04-30 08:43  峫噁Da兎兎  阅读(130)  评论(0编辑  收藏  举报