I am writing a barcode generator in C# I can generate barcodes as bitmaps and can show them in a Picturebox(WindowsForms). On the other hand I could not save my barcode as a
I had this problem before, and I was able to solve it using an intermediate bitmap object, something like this:
Bitmap barCode = CreateBarCode("*"+txtBarCodeStr.Text+"*");
//Use an intermediate bitmap object
Bitmap bm = new Bitmap(barCode);
bm.Save(@"C:\barcode.gif", ImageFormat.gif);
picBox.Image = barCode;
MessageBox.Show("Created");
I found this solution/workaround here
The reason is because "You are trying to write to a file which already has a bitmap image open on it" as @Plutonix mentioned before.