Ejemplo n.º 1
0
        internal static string InsecureGetFullPath(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (path.Trim().Length == 0)
            {
                string text = Locale.GetText("The specified path is not of a legal form (empty).");
                throw new ArgumentException(text);
            }
            if (Environment.IsRunningOnWindows)
            {
                path = Path.WindowsDriveAdjustment(path);
            }
            char c = path[path.Length - 1];

            if (path.Length >= 2 && Path.IsDsc(path[0]) && Path.IsDsc(path[1]))
            {
                if (path.Length == 2 || path.IndexOf(path[0], 2) < 0)
                {
                    throw new ArgumentException("UNC paths should be of the form \\\\server\\share.");
                }
                if (path[0] != Path.DirectorySeparatorChar)
                {
                    path = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                }
                path = Path.CanonicalizePath(path);
            }
            else
            {
                if (!Path.IsPathRooted(path))
                {
                    path = Directory.GetCurrentDirectory() + Path.DirectorySeparatorStr + path;
                }
                else if (Path.DirectorySeparatorChar == '\\' && path.Length >= 2 && Path.IsDsc(path[0]) && !Path.IsDsc(path[1]))
                {
                    string currentDirectory = Directory.GetCurrentDirectory();
                    if (currentDirectory[1] == Path.VolumeSeparatorChar)
                    {
                        path = currentDirectory.Substring(0, 2) + path;
                    }
                    else
                    {
                        path = currentDirectory.Substring(0, currentDirectory.IndexOf('\\', currentDirectory.IndexOf("\\\\") + 1));
                    }
                }
                path = Path.CanonicalizePath(path);
            }
            if (Path.IsDsc(c) && path[path.Length - 1] != Path.DirectorySeparatorChar)
            {
                path += Path.DirectorySeparatorChar;
            }
            string text2;

            if (MonoIO.RemapPath(path, out text2))
            {
                path = text2;
            }
            return(path);
        }