您的位置:首页 > 其它

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

2012-09-25 17:10 183 查看
//分离路径 文件名   后缀名

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

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: