EpLibrary.cs.FolderHelper.GetFileTitle C# (CSharp) Method

GetFileTitle() public static method

Return the simple name of the file without extension
public static GetFileTitle ( String filePath ) : String
filePath String the full path of the file with file name
return String
        public static String GetFileTitle(String filePath)
        {
            String tmpString = filePath;
            String retString = "";
            int strLength = tmpString.Length;
            for (int stringTrav = strLength - 1; stringTrav >= 0; stringTrav--)
            {
                if (tmpString[stringTrav].CompareTo('.')==0)
                {
                    tmpString=tmpString.Remove(stringTrav,tmpString.Length- stringTrav);
                    break;
                }
            }

            strLength = tmpString.Length;
            for (int stringTrav = strLength - 1; stringTrav >= 0; stringTrav--)
            {
                if (tmpString[stringTrav].CompareTo('\\')==0)
                {
                    tmpString = tmpString.Remove(0, stringTrav + 1);
                    retString = tmpString;
                    break;
                }
            }
            return retString;
        }

Usage Example

Example #1
0
 /// <summary>
 /// Return file title
 /// </summary>
 /// <returns>file title</returns>
 public String GetFileTitle()
 {
     return(FolderHelper.GetFileTitle(saveFileDialog.FileName));
 }