As noted by another poster, this is a proper superset of the set of characters returned by Path.GetInvalidPathChars(). You can use the
The following line of code to detect thisfunction detects the exact set of 41 characters shown above:
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack Internal As noted by another poster, this is a proper superset of the set of characters returned by Path.GetInvalidPathChars(). You can use the
The following line of code to detect thisfunction detects the exact set of 41 characters shown above:
As noted by another poster, this is a proper superset of the set of characters returned by Path.GetInvalidPathChars(). You can use the following line of code to detect this exact set of characters:
As noted by another poster, this is a proper superset of the set of characters returned by Path.GetInvalidPathChars().
The following function detects the exact set of 41 characters shown above:
public static bool IsBadCharIsInvalidFileNameChar(Char c) => c < 64U ? (1UL << c & 0xD4008404FFFFFFFFUL) != 0 : c == '\\' || c == '|'; public static bool IsBadChar(Char c) => c < 64U ? (1UL << c & 0xD4008404FFFFFFFFUL) != 0 : c == '\\' || c == '|'; public static bool IsInvalidFileNameChar(Char c) => c < 64U ? (1UL << c & 0xD4008404FFFFFFFFUL) != 0 : c == '\\' || c == '|'; As of .NET 4.7.2, Path.GetInvalidFileNameChars() reports the following 41 'bad' characters.
0x0000 0 '\0' | 0x000d 13 '\r' | 0x001b 27 '\u001b' 0x0001 1 '\u0001' | 0x000e 14 '\u000e' | 0x001c 28 '\u001c' 0x0002 2 '\u0002' | 0x000f 15 '\u000f' | 0x001d 29 '\u001d' 0x0003 3 '\u0003' | 0x0010 16 '\u0010' | 0x001e 30 '\u001e' 0x0004 4 '\u0004' | 0x0011 17 '\u0011' | 0x001f 31 '\u001f' 0x0005 5 '\u0005' | 0x0012 18 '\u0012' | 0x0022 34 '"' 0x0006 6 '\u0006' | 0x0013 19 '\u0013' | 0x002a 42 '*' 0x0007 7 '\a' | 0x0014 20 '\u0014' | 0x002f 47 '/' 0x0008 8 '\b' | 0x0015 21 '\u0015' | 0x003a 58 ':' 0x0009 9 '\t' | 0x0016 22 '\u0016' | 0x003c 60 '<' 0x000a 10 '\n' | 0x0017 23 '\u0017' | 0x003e 62 '>' 0x000b 11 '\v' | 0x0018 24 '\u0018' | 0x003f 63 '?' 0x000c 12 '\f' | 0x0019 25 '\u0019' | 0x005c 92 '\\' | 0x001a 26 '\u001a' | 0x007c 124 '|'
As noted by another poster, this is a proper superset of the set of characters returned by Path.GetInvalidPathChars(). You can use the following line of code to detect this exact set of characters:
public static bool IsBadChar(Char c) => c < 64U ? (1UL << c & 0xD4008404FFFFFFFFUL) != 0 : c == '\\' || c == '|';