CSKernelFile.cFileEx.fileGetFileExt C# (CSharp) Method

fileGetFileExt() public method

public fileGetFileExt ( String fullPath ) : String
fullPath String
return String
        public String fileGetFileExt(String fullPath)
        {
            String path = "";
            String fileName = "";
            int pos = 0;
            String c = "";

            separatePathAndFileName(fullPath, ref path, ref fileName);

            pos = fileName.Length;

            if (pos == 0)
            {
                return "";
            }

            c = fileName.Substring(pos, 1);
            while (c != ".")
            {
                pos = pos - 1;
                if (pos == 0) { break; }
                c = fileName.Substring(pos, 1);
            }

            switch (pos)
            {
                case 0:
                    // if there is not a separator this file doesn't have extension
                    //
                    return "";

                default:
                    // return the extension
                    //
                    return fileName.Substring(pos + 1);
            }
        }