You should try catch it as it isnt garunteed to work even with a good name as
permissions or name clashes could still get in the way. Plus it may change in
future OS's. Spaces didnt used to be allowed in windows.
Ciaran O'Donnell
> Hi !
> I have determined, that Path.InvalidPathChars does not return an array
[quoted text clipped - 6 lines]
>
> Regards
> Hi !
> I have determined, that Path.InvalidPathChars does not return an array
> with all invalid path characters. For instance the question mark (?)
> does not appear in the array, but it is not possible to create a folder
> with a question mark (?).
Hi,
MSDN: This array (InvalidPathChars) is not guaranteed to contain the
complete set of characters that are invalid in file and directory
names. The full set of invalid characters can vary by file system...
> How can I get the whole range of invalid path characters ? Or is it the
> best way, to create a folder and using try/catch ?
>
> Regards
Alternative way is to leave in the path name only exactly valid
characters instead of looking for possible invalid ones.
Ex.:
string path = @"c:\\test\df ?sdg\1.txt";
System.Text.RegularExpressions.Regex re = new
System.Text.RegularExpressions.Regex(@"[^\w\\:.]+");
path = re.Replace(path, "");
Maybe it helps somehow.
schaf - 23 Nov 2006 10:12 GMT
Hi marss
> Alternative way is to leave in the path name only exactly valid
> characters instead of looking for possible invalid ones.
[quoted text clipped - 4 lines]
> path = re.Replace(path, "");
> Maybe it helps somehow.
I have a similar alternative way, I do not want to update my regex or
char-array, each time the user changes the OS. And I'm not sure, if the
chinese version of windows has the same invalid character like a german
or english windows.