閱讀960 返回首頁    go 阿裏雲 go 技術社區[雲棲]


分析文件路徑、文件名、拓展名

        private void btnFile_Click(object sender, EventArgs e)
        {
            if (odlgFile.ShowDialog() == DialogResult.OK)
            {
                //
                //獲取文件全路徑
                //
                string strRoot = odlgFile.FileName;                  
                lblPath.Text = strRoot;
                //
                //獲取文件名
                //
                int iBeginIndex = strRoot.LastIndexOf(@"\") + 1;
                int iEndIndex = strRoot.LastIndexOf(".");
                lblFileName.Text = strRoot.Substring(iBeginIndex,   
                    iEndIndex - iBeginIndex);
                //
                //獲取文件拓展名
                //
                iBeginIndex = strRoot.LastIndexOf(".") + 1;
                iEndIndex = strRoot.Length;
                lblExtendName.Text = strRoot.Substring(iBeginIndex, 
                    iEndIndex - iBeginIndex);
            }
        }

最後更新:2017-04-02 00:06:49

  上一篇:go JSP基礎4
  下一篇:go spfa優化 SLF LLL