阅读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