c# - Zebra won't print when I write filestream -
i trying print raw zpl data zebra printer using byte array. when run program nothing prints , program passes through no issue. time print asking if step through , check filestream values before close it, label print. can causing this?
update: made suggested adjustments code , winapp.
public bool labelprinting(datatable dt, string lblpath) { if (file.exists(lblpath)) { string strcontent = ""; string comport = cboport.text.trim(); streamreader myfile = new streamreader(lblpath); strcontent = myfile.readtoend(); myfile.close(); if (strcontent.length == 0) { return false; } else { char[] bigspacechars = { convert.tochar(0x09) }; strcontent = strcontent.replace(new string(bigspacechars), " "); strcontent = strcontent.replace("<cpn>", dt.rows[0]["cpn"].tostring().toupper()); strcontent = strcontent.replace("<rackasset>", dt.rows[0]["rackasset"].tostring().toupper()); strcontent = strcontent.replace("<loc>", dt.rows[0]["loc"].tostring().toupper()); byte[] buffer = new byte[strcontent.length]; buffer = system.text.encoding.ascii.getbytes(strcontent); safefilehandle printer = createfile(comport,fileaccess.readwrite,0,intptr.zero,filemode.open,0,intptr.zero); if (printer.isinvalid == true) { return false; } using (filestream com = new filestream(printer, fileaccess.readwrite)) { com.write(buffer, 0, buffer.length); com.flush(); com.close(); } } return true; }
Comments
Post a Comment