File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/TestableIO.System.IO.Abstractions.TestingHelpers Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1- using System . Linq ;
1+ using System ;
2+ using System . Linq ;
23
34namespace System . IO . Abstractions . TestingHelpers ;
45
@@ -97,6 +98,14 @@ public bool HasIllegalCharacters(string path, bool checkAdditional)
9798
9899 if ( checkAdditional )
99100 {
101+ // AdditionalInvalidPathChars includes '?', but this character is allowed in extended-length
102+ // windows path prefixes (`\\?\`). If we're dealing with such a path, check for invalid
103+ // characters after the prefix.
104+ // Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
105+ const string EXTENDED_LENGTH_PATH_PREFIX = @"\\?\" ;
106+ if ( XFS . IsWindowsPlatform ( ) && path . StartsWith ( EXTENDED_LENGTH_PATH_PREFIX ) )
107+ path = path . Substring ( EXTENDED_LENGTH_PATH_PREFIX . Length ) ;
108+
100109 return path . IndexOfAny ( invalidPathChars . Concat ( AdditionalInvalidPathChars ) . ToArray ( ) ) >= 0 ;
101110 }
102111
@@ -164,4 +173,4 @@ public bool TryNormalizeDriveName(string name, out string result)
164173 result = name ;
165174 return true ;
166175 }
167- }
176+ }
You can’t perform that action at this time.
0 commit comments