What do you mean by this will not do anything? I ran the following in a console application:
string name = ";;;'']][[ zion \\\\[[[]]]";
char[] invalidChars = System.IO.Path.GetInvalidPathChars();
string invalidString = Regex.Escape(new string(invalidChars));
string valid = Regex.Replace(name, "[" + invalidString + "]", "");
Console.WriteLine(valid);
By the way, your syntax was incorrect, you had some unescaped characters, and you were missing a semicolon.
.
;;;'']][[ zion \\[[[]]]
. , , , , , , .
:
? , , , :
System.IO.Path.GetInvalidFileNameChars();
:
, GetInvalidPathChars()
RealInvalidPathChars = new char[] {
'"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v',
'\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b',
'\x001c', '\x001d', '\x001e', '\x001f'
};
, ASCII/Unicode 1 31, ("), (<), ( > ), pipe (|), backspace (\ b), null (\ 0) tab (\ t).
.