//分离路径 文件名 后缀名
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
}
//分离路径 文件名 后缀名
最新推荐文章于 2023-11-14 23:59:04 发布