Exemple #1
0
        /// <summary>
        /// 快捷生成验证码
        /// </summary>
        /// <param name="filePath">生成的图片的存放路径</param>
        /// <returns>生成的验证字符串</returns>
        public static string Generate(string filePath)
        {
            ValidateCodeUtil helper = new ValidateCodeUtil();

            helper.CreateImage();
            helper.Bitmap.Save(filePath);
            return(helper.Text);
        }
Exemple #2
0
        /// <summary>
        /// 快捷生成验证码
        /// </summary>
        /// <param name="filePath">生成的图片的存放路径</param>
        /// <param name="option">配置</param>
        /// <returns>生成的验证字符串</returns>
        public static string Generate(string filePath, ValidateCodeOption option)
        {
            ValidateCodeUtil helper = new ValidateCodeUtil(option);

            helper.CreateImage();
            string dir = Path.GetDirectoryName(filePath);

            if (!Directory.Exists(dir))
            {
                lock (typeof(ValidateCodeUtil))
                {
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                }
            }
            helper.Bitmap.Save(filePath);
            return(helper.Text);
        }