在C#中直接引用ThoughtWorks.QRCode.dll 类,
下载 dll 类
http://file.111cn.net/download/2013/06/29/201205161654200565.rar
protected void Button1_Click(object sender, EventArgs e) { QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;//编码方式(ALPHA_NUMERIC:字母和数字,BYTE:为字节,多用于汉字,NUMERIC:数字) qrCodeEncoder.QRCodeScale = 4;//大小(值越大生成的二维码图片像素越高) qrCodeEncoder.QRCodeVersion = 7; //版本(注意:设置为0主要是防止编码的字符串太长时发生错误,7) qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;//错误效验、错误更正(有4个等级) string data = "NI ";//这里是分销商路径 String ls_fileName = "P"+DateTime.Now.ToString("yyyyMMddhhmmss") +".png"; String ls_savePath = Server.MapPath(".") + "/QRCodeImages/" + ls_fileName;// //System.Text.Encoding.GetEncoding("GB2312")//如果内容是中文需要编码(utf-8,GB2312) qrCodeEncoder.Encode(data, System.Text.Encoding.GetEncoding("utf-8")).Save(ls_savePath); Image1.ImageUrl=("QRCodeImages/" + ls_fileName); }