Thursday, January 15, 2009

Export MIME Types from IIS – C#

Last month I wrote a post on how to export MIME Types from IIS. I also provided a little gadget to “do the job”. That tool was written in VBScript. However, I’ve received a couple of e-mails asking me how the same task could be accomplished using just C#. Well, it’s actually quite simple, here’s the CS file (GitHub) with the code.

You only need to add two references to the project were you add this file:
      – System.DirectoryServices;
      – Active DS IIS Namespace provider (needed in order to use the IISOle provider). This is in the COM tab on the Add Reference dialog.

That’s it. The call to the function in the CS file should look something like:


Those of you who asked for this CS file, please give some feedback. This is for .NET Framework 3.5.