admin管理员组文章数量:1568309
/// <summary>From:www.13le
/// 生成二维码
/// </summary>
/// <param name="content">带生成二维码的字符串</param>
/// <param name="path">路径</param>
/// <returns></returns>
public static string CreateQrCode(string content, string path)
{
if (string.IsNullOrEmpty(content))
{
throw new ArgumentNullException(content);
}
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException(path);
}
var qrCodeEncoder = new QRCodeEncoder
{
QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,
QRCodeScale = 4,
QRCodeVersion = 8,
QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M
};
Image image = qrCodeEncoder.Encode(content);
var filename = DateTime.Now.ToString("yyyymmddhhmmssfff") + ".jpg";
var filepath = string.Format("{0}{1}", path, filename);
FileStream fs = null;
try
{
fs = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write);
image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (IOException ex)
{
throw new IOException(ex.Message);
}
finally
{
if (fs != null) fs.Close();
image.Dispose();
}
return CodeDecoder(filepath);
}
本文标签: 二维码thoughtworks
版权声明:本文标题:c# ThoughtWorks 生成二维码 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1726875833a1088339.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论