Fixing “Generic error occurred in GDI+” while generating a Barcode

前端 未结 6 2021
春和景丽
春和景丽 2021-01-02 13:11

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

6条回答
  •  盖世英雄少女心
    2021-01-02 13:17

    I found a simple solution for it:

    1. Create a folder in solution, for example, I created Template folder in solution(Inside the project).
    2. Then try to save your file into that folder with Server.MapPath, for example, Bitmap.Save(HttpContext.Current.Server.MapPath("/Template/3777.jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg);
    3. And Finally return HttpContext.Current.Server.MapPath("/Template/3777.jpeg");
    4. For me it worked well and advantage of this method is the file that you want to save,not saving into the folder but when you return,it fetches the file

提交回复
热议问题