在GDI+中发生了一个通用错误.无法打印条形码
本文关键字:错误 条形码 打印 一个 GDI+ 发生了 | 更新日期: 2023-09-27 17:53:57
我得到以下错误
下面是我的代码[ExternalException (0x80004005): A generic error occurred in GDI+.]System.Drawing.Image。保存(字符串文件名,ImageCodecInfo编码器,EncoderParameters encoderParams) +813085InventoryMS.PrintBarcodes。Page_Load(对象发送者,EventArgs e) +766System.Web.UI.Control.LoadRecursive () + 71System.Web.UI.Page。ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PrintBarcodes.aspx.cs" Inherits="InventoryMS.PrintBarcodes" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title><link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/font-awesome.css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="getCodetxt" runat="server" Visible="True"></asp:TextBox>
<asp:Panel ID="pnlPrint" runat="server">
<br />
<%
int number = Convert.ToInt32(Session["val"].ToString());
int t = 1;
for (int i = 0; i < number; i++)
{
%>
<div style="width:130px; height:99px; float:left; margin-left:17px;">
<p style="text-align:center; margin-left:0px; margin-bottom:-17px; width:120px;font-size:11px">Testing Company</p><br />
<asp:Image ID="img" runat="server" Style="margin-bottom:12px;margin-left:-5px; height:43px; width:130px;"/><br />
<p style="margin-top:-13px; font-size:10px; text-align:center">Size:<asp:Label ID="lblsize" runat="server" Text=""></asp:Label></p>
</div>
<% if (t == 2)
{
t = 1;
%>
<br />
<%
}
else { t++; }
}
%>
</asp:Panel>
</div>
</form>
</body>
</html>
请指导我解决这个问题
从我的错误来看,这个错误通常与文件路径有关。请确保您要保存到的文件夹存在,并且您具有写权限。