List characters that are illegal in file and path names in C#

string txt = "";The code simply loops through the values returned by Path.GetInvalidFileNameChars and Path.GetInvalidPathChars. It displays the printable characters and shows the numeric values of the whitespace and control characters. Download example
foreach (char ch in Path.GetInvalidFileNameChars())
{
if (Char.IsWhiteSpace(ch) || Char.IsControl(ch))
{
txt += "<" + (int)ch + "> ";
}
else
{
txt += ch + " ";
}
}
lblInvalidFileNameChars.Text = txt;
txt = "";
foreach (char ch in Path.GetInvalidPathChars())
{
if (Char.IsWhiteSpace(ch) || Char.IsControl(ch))
{
txt += "<" + (int)ch + "> ";
}
else
{
txt += ch + " ";
}
}
lblInvalidPathChars.Text = txt;
-->
Comments