Directly referencing the ThoughtWorks.QRCode.dll class in C #,
Download DLL Classes
Http://file.111cn.net/download/2013/06/29/201205161654200565.rar
protected voidButton1_Click (Objectsender, EventArgs e) {Qrcodeencoder Qrcodeencoder=NewQrcodeencoder (); Qrcodeencoder.qrcodeencodemode= Qrcodeencoder.encode_mode. Alpha_numeric;//encoding Method (Alpha_numeric: Letters and Numbers, byte: bytes, more for Chinese characters, NUMERIC: Numbers)Qrcodeencoder.qrcodescale =4;//size (the larger the value, the higher the image pixel of the resulting QR code)Qrcodeencoder.qrcodeversion =7;//Version (note: setting to 0 is primarily to prevent the encoding of strings from being too long when an error occurs, 7)Qrcodeencoder.qrcodeerrorcorrect = qrcodeencoder.error_correction. M//error validation, error correction (4 levels) stringdata ="NI";//here is the reseller pathString Ls_filename ="P"+datetime.now.tostring ("YYYYMMDDHHMMSS") +". PNG"; String Ls_savepath= Server.MapPath (".") +"/qrcodeimages/"+ Ls_filename;// //System.Text.Encoding.GetEncoding ("GB2312")//If the content is in Chinese need to encode (utf-8,gb2312)Qrcodeencoder.encode (data, System.Text.Encoding.GetEncoding ("Utf-8")). Save (Ls_savepath); Image1.imageurl=("qrcodeimages/"+ls_filename); }
Two-dimensional code generation demo