Directly referencing the ThoughtWorks.QRCode.dll class in C #,
Qrcodeencoder Qrcodeencoder = new Qrcodeencoder ();
Qrcodeencoder.qrcodeencodemode = Qrcodeencoder.encode_mode. BYTE; Encoding method (Note: Byte can support Chinese, alpha_numeric scan out is the number)
Qrcodeencoder.qrcodescale = 4; Size (the larger the value, the higher the image pixel of the resulting QR code)
Qrcodeencoder.qrcodeversion = 8; Version (note: setting to 0 is primarily to prevent an error when the encoded string is too long)
Qrcodeencoder.qrcodeerrorcorrect = qrcodeencoder.error_correction. M Error validation, error correction (4 levels)
String data = "http://www.xxxxx.com/register.aspx?refpeople=" + username + ""; Two-dimensional code information
Context. Response.Write (data);
System.Drawing.Bitmap image = Qrcodeencoder.encode (data);
System.IO.MemoryStream mstream = new System.IO.MemoryStream ();
Image. Save (Mstream, System.Drawing.Imaging.ImageFormat.Png);
Context. Response.clearcontent ();
Context. Response.ContentType = "Image/png";
Context. Response.BinaryWrite (Mstream.toarray ());
String path = context. Server.MapPath ("~/uploadfile/twocode");
Directory.CreateDirectory (path);
Path = path + "\ \" + DateTime.Now.ToString ("YYYYMMDDHHMMSS") + ". png";
FileStream fs = new FileStream (path, filemode.createnew, FileAccess.ReadWrite);
BinaryWriter bw = new BinaryWriter (FS, Utf8encoding.utf8);
byte[] by = Mstream.toarray ();
for (int i = 0; i < Mstream.toarray (). Length; i++)
Bw. Write (By[i]);
Fs. Close ();
String relativepath = "/uploadfile/twocode/" + DateTime.Now.ToString ("YYYYMMDDHHMMSS") + ". png";
C # generates two-dimensional code