title: How to get get number of pages in a tiff file with code in a Windows Service
body: <p>I have a Windows service that tries to get the number of pages in a TIFF file using the Image class in the System.Drawing namespace.</p>
  
  <pre><code>    using System.Drawing;
  
      private int GetNumberOfPagesFromTiffFile(string filePath)
      {
          int pageCount = 0;
          Image Tiff = Image.FromFile(filePath);
          pageCount = Tiff.GetFrameCount(FrameDimension.Page);
          Tiff.Dispose(); 
  
          return pageCount;
      }
  </code></pre>
  
  <p>But the Microsoft documentation <a href="http://msdn.microsoft.com/en-us/library/system.drawing.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.drawing.aspx</a> says not to use System.Drawing in a Windows service.  They suggested using Windows Imaging Component.  I downloaded it to see if it has a way to get the number of pages in a TIFF file, but I got an error installing it.  So I don't have my answer yet.</p>
  
  <p>I'm curious what others use to get the number of pages in a TIFF file in a Windows service.</p>