Reputation: 1704
I want to output a human-readable list of invalid path characters as understood by .NET's runtime.
I've tried both Linqpad and a simple Console.WriteLine(Path.GetInvalidPathChars)
console application, but both display certain characters illegibly. Apparently, this is expected.
Note: Some characters may not be displayable on the console.
Is the documentation telling me I can't get a human-readable version of these characters?
Upvotes: 1
Views: 181
Reputation: 614
Some characters does not have any visual representation that can be written in regular console. I would do something like this:
var chars = Path.GetInvalidPathChars().Select(x => (int)x);
foreach (char c in Path.GetInvalidPathChars())
{
Console.WriteLine("(char)" + (int)c + ": " + c );
}
Upvotes: 3
Reputation: 157038
Yes, some characters are invalid though not readable. For example the null terminator character \0
has no visible representation. Some fonts will render such characters as a question mark box, some have quite funny ways of (not) showing it.
Bottom line is, you have to replace those characters by some 'human readable' text, instead of their visual representation.
Upvotes: 1