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

GetFileExtension() public static method

Return only the extension of given file path
public static GetFileExtension ( String filePath ) : String
filePath String the full path of the file with file name
return String
        public static String GetFileExtension(String filePath)
        {
            String tmpString = filePath;
            //size_t strLength=System::TcsLen(filePath);
            int strLength = tmpString.Length;
            String retString = "";
            for (int stringTrav = strLength - 1; stringTrav >= 0; stringTrav--)
            {
                if (tmpString[stringTrav].CompareTo('.')==0)
                {
                    retString=tmpString.Remove(0, stringTrav + 1);
                    break;
                }
            }
            return retString;
        }

Usage Example

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