CSKernelFile.cFileEx.separatePathAndFileName C# (CSharp) Method

separatePathAndFileName() public static method

public static separatePathAndFileName ( String fullPath, String &path, String &fileName ) : void
fullPath String
path String
fileName String
return void
        public static void separatePathAndFileName(String fullPath, ref String path, ref String fileName)
        {
            int pos = 0;
            String sep = "";

            pos = fullPath.Length;

            if (pos == 0)
            {
                path = fullPath;
                fileName = fullPath;
                return;
            }
            sep = fullPath.Substring(pos, 1);
            while (!isSeparator(sep))
            {
                pos = pos - 1;
                if (pos == 0) { break; }
                sep = fullPath.Substring(pos, 1);
            }

            if (pos == fullPath.Length-1)
            {
                // if the separator is founded at the end it must be a root folder example: c:\
                //
                path = fullPath.Substring(0, pos - 1);
                fileName = fullPath;
            }
            else if (pos == 0)
            {
                // if the separator is not found it must be a root folder example: c:
                //
                path = fullPath;
                fileName = fullPath;
            }
            else
            {
                path = fullPath.Substring(0, pos - 1);
                fileName = fullPath.Substring(pos + 1);
            }
        }