///
/// 分离出文件名 路径 后缀
///
/// 包括文件名和路径
/// 返回数组 0 path 1 filename 2 suffix
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;
}