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

GetFileName() public static method

Return the simple name of the file
public static GetFileName ( String filePath ) : String
filePath String the full path of the file with file name
return String
        public static String GetFileName(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(0, stringTrav + 1);
                    retString = tmpString;
                    break;
                }
            }
            return retString;
        }

Usage Example

Example #1
0
 /// <summary>
 /// Return only filename
 /// </summary>
 /// <returns>filename</returns>
 public String GetFileName()
 {
     return(FolderHelper.GetFileName(saveFileDialog.FileName));
 }