title: C# remove unallowed folder name characters
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/62771/how-check-if-given-string-is-legal-allowed-file-name-under-windows">How check if given string is legal (allowed) file name under Windows?</a>  </p>
  </blockquote>
  
  
  
  <p>I have searched about, spent some minutes googling, but i cant apply what i have found, to my context..</p>
  
  <pre><code>string appPath = Path.GetDirectoryName(Application.ExecutablePath);
          string fname = projectNameBox.Text;
          if (projectNameBox.TextLength != 0)
          {
  
              File.Create(appPath + "\\projects\\" + fname + ".wtsprn");
  </code></pre>
  
  <p>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</p>