liukuo362573 / YiShaAdmin

基于 .NET Core MVC 的权限管理系统,代码易读易懂、界面简洁美观
MIT License
2.42k stars 872 forks source link

Zxing.NET 在Controller中生成二维码并保存在项目根目录中, 会导致项目重新加载全局变量。 这是为什么? #165

Open Yuanliang-xxxxx opened 8 months ago

Yuanliang-xxxxx commented 8 months ago

public void generateQcode(string Code,int Width, int Height, int type = 0) { try { string severPath = getfilepath(); EncodingOptions encodingOptions = null; BarcodeWriter barcodeWriter = null; encodingOptions = new EncodingOptions { Width = Width, Height = Height }; barcodeWriter = new BarcodeWriter(); if (type == 1) { barcodeWriter.Format = BarcodeFormat.QR_CODE; } else { barcodeWriter.Format = BarcodeFormat.CODE_128; }

            barcodeWriter.Options = encodingOptions;
            string text = Code + ".jpg";
            Bitmap bitmap = barcodeWriter.Write(Code);
            if (!DirFileHelper.IsExistDirectory(severPath))
            {
                DirFileHelper.CreateDirectory(severPath);
            }

            string filename = severPath + text;
            bitmap.Save(filename);
            bitmap.Dispose();
        }
        catch (Exception ex)
        {

            throw ex;
        }

    }
Yuanliang-xxxxx commented 8 months ago

有咩有大佬