//分离路径 文件名 后缀名

//分离路径 文件名   后缀名

        OpenFileDialog openFileDialog1 = new OpenFileDialog();
        public void splitPathFileNameSuffix()
        {
            openFileDialog1.Filter = "All files(*.*)|*.*"; //设置打开文件的类型
            openFileDialog1.ShowDialog();
            string fullName = openFileDialog1.FileName.ToString();
            string strPath = fullName.Substring(0, fullName.LastIndexOf("\\")); //get path
            string strFileName = fullName.Substring( fullName.LastIndexOf("\\") +1, (fullName.LastIndexOf(".") - fullName.LastIndexOf("\\") -1) ); //get file name 
            string strSuffix = fullName.Substring( fullName.LastIndexOf(".") +1,(fullName.Length- fullName.LastIndexOf(".") - 1 )); //get suffix

        }

你可能感兴趣的:(String,File,Path)