分离出文件名 路径 后缀
2014-05-22 12:42
357 查看
/// <summary> /// 分离出文件名 路径 后缀 /// </summary> /// <param name="fullName">包括文件名和路径</param> /// <returns>返回数组 0 path 1 filename 2 suffix </returns> public string[] splitFileNamePathSuffix(string fullName) { string[] fileSplit = new string[3]; if (String.IsNullOrEmpty(fullName)) return null; if (fullName.Contains("\\"))//windows mode { fileSplit[0] = fullName.Substring(0, fullName.LastIndexOf("\\")); //get path fileSplit[1] = fullName.Substring(fullName.LastIndexOf("\\") + 1, (fullName.LastIndexOf(".") - fullName.LastIndexOf("\\") - 1)); //get file name fileSplit[2] = fullName.Substring(fullName.LastIndexOf(".") + 1, (fullName.Length - fullName.LastIndexOf(".") - 1)); //get suffix } if (fullName.Contains("/"))//unix mode { fileSplit[0] = fullName.Substring(0, fullName.LastIndexOf("/")); //get path fileSplit[1] = fullName.Substring(fullName.LastIndexOf("/") + 1, (fullName.LastIndexOf(".") - fullName.LastIndexOf("/") - 1)); //get file name fileSplit[2] = fullName.Substring(fullName.LastIndexOf(".") + 1, (fullName.Length - fullName.LastIndexOf(".") - 1)); //get suffix } return fileSplit; }
相关文章推荐
- python 分离文件名和路径以及分离文件名和后缀的方法
- VC 中如何从字符串中分离文件名与路径
- C++程序中获取不带文件路径和后缀的文件名
- 分离目录路径和文件名
- php从完整文件路径中分离文件目录和文件名的方法
- 如何从完整的文件路径中分离文件名和路径名?
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名。
- 丶从字符串中分离文件路径、文件名和扩展名
- iPhone-获取网络数据或者路径的文件名以及后缀
- [C语言(VC)] 从路径字符串中分离出文件名
- DOS命令应用之分离路径和文件名
- iPhone-获取网络数据或者路径的文件名以及后缀
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- iPhone-获取网络数据或者路径的文件名以及后缀
- C++程序中获取不带文件路径和后缀的文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- C# 根据绝对路径获取 带后缀文件名、后缀名、文件名、不带文件名的文件路径
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- DOS命令应用之分离路径和文件名