Possible Duplicate:
How check if given string is legal (allowed) file name under Windows?
I have searched about, spent some minutes googling, but i cant apply what i have found, to my context..
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
string fname = projectNameBox.Text;
if (projectNameBox.TextLength != 0)
{
File.Create(appPath + "\\projects\\" + fname + ".wtsprn");
So, i am retrieving the projectNameBox.Text and creating a file with the text as filename, but if i include a :, or a \ or a / etc.. it will just crash, which is normal, as those are not allowed for a folder name..How can i check the text, before the file creation, and remove the characters, or even better, do nothing and advise the user that he can not use those characters? Thanks in advance