生成二维码

在BS架构下,通过后台生成二维码

1.引用类库,ThoughtWorks.QRCode.dll密码:1024。

2.代码:

string msg = "00000000001980";

Bitmap bt;

string enCodeString = DateTime.Now.ToString();

QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);

string filename = msg + ".jpg";

filename = filename.Replace(" ", "");

filename = filename.Replace(":", "");

 filename = filename.Replace("-", "");

//filename = filename.Replace(".", "");

 if (!Directory.Exists(@"C:\二维码\"))

 {

        Directory.CreateDirectory(@"C:\二维码\");

}

filename = @"C:\二维码\" + filename;

bt.Save(filename, ImageFormat.Png);

 

posted @ 2019-01-30 10:59 756001160 阅读(...) 评论(...) 编辑 收藏