Using system;using system.collections.generic;using system.linq;using system.text;using BarcodeLib;using System.IO; Namespace tool.gui{public class Clslisbarcode {Barcode M_barcoe = new Barcode (); String M_strpath; Public Clslisbarcode () {M_strpath = System.Windows.Forms.Application.StartupPath + @ "\temp"; }///p_strbmpfile file path public void Createcodebmp (string p_strcode, out string p_strbmpfile) {Crea Tecodebmp (P_strcode, Out P_strbmpfile, ""); }///p_strbmpfile file path public void Createcodebmp (string p_strcode, out string p_strbmpfile, String p_strtype) {if (! Directory.Exists (M_strpath)) {directory.createdirectory (M_strpath); } try {foreach (string file in Directory.GetFiles (M_strpath)) { File.delete (file); }} catch {} P_Strbmpfile = ""; Type type = type. UNSPECIFIED; Switch (p_strtype) {case "UPCA": type = type. UPCA; Break Case "upc-a (numbered)": type = type. UPCA; Break Case "UPC-E": type = type. UPCE; Break Case "UPC 2 Digit Ext.": type = type. Upc_supplemental_2digit; Break Case "UPC 5 Digit Ext.": type = type. Upc_supplemental_5digit; Break Case "EAN13": type = type. EAN13; Break Case "JAN13": type = type. JAN13; Break Case "EAN8": type = type. EAN8; Break Case "ITF14": type = type. ITF14; Break Case "Codabar": type = type. Codabar; Break Case "PostNet": type = type. PostNet; Break Case "BOOKLAND/ISBN": type = type. Bookland; Break Case "CODE11": type = type. CODE11; Break Case "Code39": type = type. CODE39; Break Case "Code39 Extended": Type = TYPE. code39extended; Break Case "Code93": type = type. CODE93; Break Case "Logmars": type = type. Logmars; Break Case "MSI": type = type. MSI_MOD10; Break Case "Interleaved 2 of 5": type = type. Interleaved2of5; Break Case ' standard 2 of 5 ': type = type. Standard2of5; Break Case "Code128": type = type. CODE128; Break Case "code128a": type = type. code128a; Break Case "code128b": type = type. code128b; Break Case "code128c": type = type. code128c; Break Default:type = type. CODE128; break;//, default format} try {if (type! = type. UNSPECIFIED) {p_strbmpfile = M_strpath + @ "\" + P_strcode + ". Bmp "; M_barcoe.includelabel = false; M_barcoe.encode (Type, P_strcode, 359, 150);//Width height m_barcoe.saveimage (p_strbmpfilE, BarcodeLib.SaveTypes.BMP); }} (Catch {}}}}
C # Generate barcode picture, good effect