title: WIA to save images in .NET C#
body: <p>I am using WIA to take a photo programatically and this image will then be copied over to a specific folder in my desktop. Everything is going well except for the saving part.</p>
  
  <pre><code>void deviceManager_OnEvent(string EventID, string DeviceID, string ItemID)
      {
  
          for (int i = 1; i &lt;= d.Items.Count; i++)
          {
              wiaImageFile = (WIA.ImageFile)d.Items[i].Transfer(FormatID.wiaFormatJPEG);
              wiaImageFile.SaveFile(Properties.Settings.Default.FolderNameRaw + "\\1.jpg");
              if (wiaImageFile != null)
                  Marshal.ReleaseComObject(wiaImageFile);
          }
      }
  </code></pre>
  
  <p>In this code, my d.Items.Count is constantly increasing(Eg. 29 which is totally diff from the actual count) even though I only have 2 photos in my camera's SD card. Is there a way to correctly transfer or even cut the file over to my computer?
  This is the exception that i receive.
  <img src="https://i.stack.imgur.com/W77Zw.png" alt="enter image description here"></p>