title: Close a file which is in use from a PictureBox
body: <p>I'm using this code for converting Excel to image and preview it in a picturebox.
  The code is working for first time. But when i'm trying to upload second time i get an error that says that the image file is in use.specically in save point.</p>
  
  <pre><code>  OpenFileDialog openFileDialog1 = new OpenFileDialog();
          openFileDialog1.Filter = "bak files (*.xls)|*.xls|All files (*.*)|*.*";
          if (openFileDialog1.ShowDialog() == DialogResult.OK)
          {
              Img1 = openFileDialog1.FileName;
  
  
              //Create a new Workbook object and
              //Open a template Excel file.
              Workbook book = new Workbook(Img1);
              //Get the first worksheet.
              Worksheet sheet = book.Worksheets[0];
  
              //Define ImageOrPrintOptions
              ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
              //Specify the image format
              imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
              //Only one page for the whole sheet would be rendered
              imgOptions.OnePagePerSheet = true;
  
              //Render the sheet with respect to specified image/print options
              SheetRender sr = new SheetRender(sheet, imgOptions);
              //Render the image for the sheet
              Bitmap bitmap = sr.ToImage(0);
  
              //Save the image file specifying its image format.
              bitmap.Save("C:\\1.jpg");\\in this point i get my error that it says general error  GDI+.
  
              pictureBox2.Image = Image.FromFile("C:\\1.jpg");
              pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
  
          }
          else
          {
              this.DialogResult = DialogResult.None;
  
          }
      }
  </code></pre>
  
  <p>I thing i must stop first use from my picturebox preview and then to upload again. But how will i do that? I tried </p>
  
  <pre><code> pictureBox1.Image=null
  </code></pre>
  
  <p>,but it didnt worked.</p>