title: Why I got this "A generic error occurred in GDI+. at System.Drawing.Image.Save" at random frequencies?
body: <p>Here's my basic code:</p>
  <pre><code>#region privateMethods
  private bool SaveImageFile(string absolutePathFile, byte[] file, ImageFormat format)
  {
      try
      {
          string directoryPath = Path.GetDirectoryName(absolutePathFile);
          if (!Directory.Exists(directoryPath)) Directory.CreateDirectory(directoryPath);
          if (File.Exists(absolutePathFile)) File.Delete(absolutePathFile);
  
          using (MemoryStream ms = new MemoryStream(file))
          using (var bmp = Image.FromStream(ms))     
              bmp.Save(absolutePathFile, format);
  
          return true;
  
      }
      catch (ArgumentException argEx)
      {
          EventLogger.WriteLog(&quot;UploadImageFile: This file it isn't an image &quot; + argEx.Message, System.Diagnostics.EventLogEntryType.Error);
      }
      catch (Exception ex)
      {
          EventLogger.WriteLog(&quot;UploadImageFile: &quot; + ex.Message + &quot; &quot; + ex.StackTrace + &quot;PathFile: &quot; + absolutePathFile, System.Diagnostics.EventLogEntryType.Error);
      }
      return false;
  }
  </code></pre>
  <p>It seems very basic. Which could be the cause? Or how can I investigate better?</p>
  <p>It seems to happens not always, but &quot;sometimes&quot;. That's really weird and under control, the randomness of the happening...</p>