From 910a64502feb63d75e114bbc1b87c16f69eb5ef5 Mon Sep 17 00:00:00 2001 From: kike-garbo Date: Mon, 9 Dec 2024 13:13:00 +0100 Subject: [PATCH] Fix on `PathExtension.IsFullyQualifiedPath` extension method. --- .../Extensions/System.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/RhinoInside.Revit.External/Extensions/System.cs b/src/RhinoInside.Revit.External/Extensions/System.cs index ad6c76130..39d2ca142 100644 --- a/src/RhinoInside.Revit.External/Extensions/System.cs +++ b/src/RhinoInside.Revit.External/Extensions/System.cs @@ -250,20 +250,24 @@ static class PathExtension public static bool IsFullyQualifiedPath(this string path) { if (path == null) return false; + +#if NET5_0_OR_GREATER + return Path.IsPathFullyQualified(path); +#else if (path.Length < 2) return false; - if (IsDirectorySeparator(path[0])) - return path[1] == '?' || IsDirectorySeparator(path[1]); - return - ( - (path.Length >= 3) && - (path[1] == Path.VolumeSeparatorChar) && - IsDirectorySeparator(path[2]) && - IsValidDriveChar(path[0]) - ); + return IsDirectorySeparator(path[0]) ? + IsDirectorySeparator(path[1]) : + ( + path.Length >= 3 && + path[1] == Path.VolumeSeparatorChar && + IsDirectorySeparator(path[2]) && + IsValidDriveChar(path[0]) + ); bool IsValidDriveChar(char value) => ('A' <= value && value <= 'Z') || ('a' <= value && value <= 'z'); bool IsDirectorySeparator(char c) => c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar; +#endif } [DllImport("SHLWAPI", CharSet = CharSet.Unicode)]