Can't save image for barcode generation in ASP.NET C# project
<p>I'm trying to save an image using System.Drawing.Save() and I keep getting a Invalid Parameter exception.</p>

<p>Can somebody please take a look at my code and tell me what I'm doing wrong.</p>

<p>Here is the code that generates the barcode image.</p>

<pre><code> public class BarcodeHelper
    {
        Font barcodeFont;
        public BarcodeHelper()
        {
             PrivateFontCollection fonts;
             FontFamily family = LoadFontFamily("~/../fonts/Code128bWin.ttf", out fonts);   
             barcodeFont = new Font(family, 20.0f);   

            // when done:   
            barcodeFont.Dispose();   
            family.Dispose();   
            family.Dispose();
        }
        public FontFamily LoadFontFamily(string fileName, out PrivateFontCollection fontCollection) 
        { 
            fontCollection = new PrivateFontCollection(); 
            fontCollection.AddFontFile(fileName); 
            return fontCollection.Families[0]; 
        }

        public Image GenerateBarcode(string barcodeText) 
        {
            Image barcodeImage;
            using (barcodeImage = Image.FromFile(@"C:\Users\Administrator\Desktop\YodelShipping\YodelShipping\images\barcode.bmp"))
            {
                using (Graphics g = Graphics.FromImage(barcodeImage))
                {
                    g.DrawString(barcodeText,
                        new Font(barcodeFont, FontStyle.Bold), Brushes.Black, 
                        barcodeImage.Height /2, barcodeImage.Width / 2);
                }
            }
            return barcodeImage;
        }
    }
</code></pre>

<p>Here is where I call the code to create and save the barcode image. I'm getting the exception, when calling the Save() method.</p>

<pre><code>System.Drawing.Image img = barcodeHelper.GenerateBarcode("2lgbub51aj+01000002");
img.Save("~/images/barcode.png");
</code></pre>

<p><img src="http://i.stack.imgur.com/7G3rs.png" alt="enter image description here"></p>
