System.Net.FtpControlStream.GetPathInfo C# (CSharp) Method

GetPathInfo() private static method

Gets the path component of the Uri

private static GetPathInfo ( GetPathOption pathOption, Uri uri, string &path, string &directory, string &filename ) : void
pathOption GetPathOption
uri System.Uri
path string
directory string
filename string
return void
        private static void GetPathInfo(GetPathOption pathOption,
                                                           Uri uri,
                                                           out string path,
                                                           out string directory,
                                                           out string filename)
        {
            path = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped);
            int index = path.LastIndexOf('/');

            if (pathOption == GetPathOption.AssumeFilename &&
                index != -1 && index == path.Length - 1)
            {
                // Remove last '/' and continue normal processing
                path = path.Substring(0, path.Length - 1);
                index = path.LastIndexOf('/');
            }

            // split path into directory and filename
            if (pathOption == GetPathOption.AssumeNoFilename)
            {
                directory = path;
                filename = string.Empty;
            }
            else
            {
                directory = path.Substring(0, index + 1);
                filename = path.Substring(index + 1, path.Length - (index + 1));
            }

            // strip off trailing '/' on directory if present
            if (directory.Length > 1 && directory[directory.Length - 1] == '/')
                directory = directory.Substring(0, directory.Length - 1);
        }