title: Which characters are invalid for folder names inside a ZIP file?
body: <p>Here's the scenario.</p>
  
  <p>I'm calling a database and pulling in around ~3000 records which are child nodes of parent documents, with these child nodes I'm working back up the tree to generate a flat folder name which looks something like this:</p>
  
  <blockquote>
    <p>Entertainment Categories ~  Artistic Entertainment ~  Calligraphy Artists ~  Megumi - Japanese Calligraphy Artist  Sussex ~ 6546</p>
  </blockquote>
  
  <p>Going from parent all the way down to child and then child ID.</p>
  
  <p>What I then do is iterate over these folder names and create a new folder using the name, this all works fine, I'm running the names through a loop using <a href="http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars%28v=vs.110%29.aspx" rel="nofollow">Path.GetInvalidFileNameChars</a> to get rid of any characters that would prevent the folder creation from failing.</p>
  
  <p>However, when it comes to zipping these folders up using the built in zip function in windows (right click > send to > compressed zip folder) I keep getting errors:</p>
  
  <blockquote>
    <p>[Folder name] cannot be compressed because it includes characters that cannot be used in a compressed folder, such as [foo]. You should rename this file or directory.</p>
  </blockquote>
  
  <p>It would be fine if the error message actually told me the range of characters that cannot be included in folder names but it doesn't, so whenever I do a replace on the character I get a new one pop up in the error message, this is what I'm doing to clean the folder name at the moment:</p>
  
  <pre><code>private static void CleanPath(StringBuilder path)
  {
      List&lt;string&gt; invalidFolderCharacters = Path.GetInvalidFileNameChars()
                                             .Select(x =&gt; x.ToString()).ToList();
      invalidFolderCharacters.Add("–");
      invalidFolderCharacters.Add("`");
      invalidFolderCharacters.Add("\'");
      invalidFolderCharacters.Add("′");
  
      foreach (string s in invalidFolderCharacters)
      {
           path.Replace(s, string.Empty);
      }
  }
  </code></pre>
  
  <p>As you can see, I'm having to add to the characters returned by <code>GetInvalidFileNameChars()</code> each time a new error pops up.</p>
  
  <p>So my question is - Is there a built in function in the .NET framework that I can use which will provide me with characters that aren't allowed in file/folder names as well as characters that cannot be in compressed folder names? Can anyone tell me what characters aren't allowed in compressed folder names so that I can create one myself?</p>