A simple two-dimensional code generator batch
Recently it requires a lot of strings to generate two-dimensional code,
find a lot of sites and applications are not very satisfactory, simply do it yourself!
Find QrCode find the next open-source project on github
QrCode open-source library
Qrcode very simple to install, read here
Reference dll
using QrCode
Core logic
/// <summary>
///
/// </summary>
/// <param name="filename"></param>
/// <param name="savedir"></param>
public void QrCodeBatch(string filename, string savedir)
{
Stopwatch sw = new Stopwatch();
string path = filename;
StreamReader sr = new StreamReader(path, Encoding.Default);
String line;
QRCodeGenerator qrGenerrateor = new QRCodeGenerator();
QRCodeData qRCodeData = null;
QRCode qrcode = null;
Bitmap qrCodeImage = null;
sw.Start();
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line.ToString());
line = line.Trim();
qRCodeData = qrGenerrateor.CreateQrCode(line, QRCodeGenerator.ECCLevel.Q);
qrcode = new QRCode(qRCodeData);
qrCodeImage = qrcode.GetGraphic(20);
qrCodeImage.Save(savedir + "\\"+line + ".png");
}
sr.Close();
// 导出数据
Console.WriteLine("use time"+sw.ElapsedMilliseconds / 1000);
}
}
Add interface
Function is complete, if someone else with a need to give a simple interface
Instructions
1, the saved string txt file
2, choose to save the generated folder
3, starts generating
4, view generated files
Download
Baidu network disk link: https://pan.baidu.com/s/1SDiWMAmvqHpfTi7zz3jZtg
extraction code: c1oo