欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#文件加密方法匯總

 更新時(shí)間:2014年11月04日 09:52:15   投稿:shichen2014  
這篇文章主要介紹了C#文件加密方法,實(shí)例匯總了常見的加密方法如AES加密類、文件加密類、文件夾加密類等,最后給出完整的實(shí)例源碼下載供大家參考借鑒,需要的朋友可以參考下

本文實(shí)例匯總了C#文件加密方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

1、AES加密類

復(fù)制代碼 代碼如下:

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace Utils
{
    /// <summary>
    /// AES加密解密
    /// </summary>
    public class AES
    {
        #region 加密
        #region 加密字符串
        /// <summary>
        /// AES 加密(高級(jí)加密標(biāo)準(zhǔn),是下一代的加密算法標(biāo)準(zhǔn),速度快,安全級(jí)別高,目前 AES 標(biāo)準(zhǔn)的一個(gè)實(shí)現(xiàn)是 Rijndael 算法)
        /// </summary>
        /// <param name="EncryptString">待加密密文</param>
        /// <param name="EncryptKey">加密密鑰</param>
        public static string AESEncrypt(string EncryptString, string EncryptKey)
        {
            return Convert.ToBase64String(AESEncrypt(Encoding.Default.GetBytes(EncryptString), EncryptKey));
        }
        #endregion

        #region 加密字節(jié)數(shù)組
        /// <summary>
        /// AES 加密(高級(jí)加密標(biāo)準(zhǔn),是下一代的加密算法標(biāo)準(zhǔn),速度快,安全級(jí)別高,目前 AES 標(biāo)準(zhǔn)的一個(gè)實(shí)現(xiàn)是 Rijndael 算法)
        /// </summary>
        /// <param name="EncryptString">待加密密文</param>
        /// <param name="EncryptKey">加密密鑰</param>
        public static byte[] AESEncrypt(byte[] EncryptByte, string EncryptKey)
        {
            if (EncryptByte.Length == 0) { throw (new Exception("明文不得為空")); }
            if (string.IsNullOrEmpty(EncryptKey)) { throw (new Exception("密鑰不得為空")); }
            byte[] m_strEncrypt;
            byte[] m_btIV = Convert.FromBase64String("Rkb4jvUy/ye7Cd7k89QQgQ==");
            byte[] m_salt = Convert.FromBase64String("gsf4jvkyhye5/d7k8OrLgM==");
            Rijndael m_AESProvider = Rijndael.Create();
            try
            {
                MemoryStream m_stream = new MemoryStream();
                PasswordDeriveBytes pdb = new PasswordDeriveBytes(EncryptKey, m_salt);
                ICryptoTransform transform = m_AESProvider.CreateEncryptor(pdb.GetBytes(32), m_btIV);
                CryptoStream m_csstream = new CryptoStream(m_stream, transform, CryptoStreamMode.Write);
                m_csstream.Write(EncryptByte, 0, EncryptByte.Length);
                m_csstream.FlushFinalBlock();
                m_strEncrypt = m_stream.ToArray();
                m_stream.Close(); m_stream.Dispose();
                m_csstream.Close(); m_csstream.Dispose();
            }
            catch (IOException ex) { throw ex; }
            catch (CryptographicException ex) { throw ex; }
            catch (ArgumentException ex) { throw ex; }
            catch (Exception ex) { throw ex; }
            finally { m_AESProvider.Clear(); }
            return m_strEncrypt;
        }
        #endregion
        #endregion

        #region 解密
        #region 解密字符串
        /// <summary>
        /// AES 解密(高級(jí)加密標(biāo)準(zhǔn),是下一代的加密算法標(biāo)準(zhǔn),速度快,安全級(jí)別高,目前 AES 標(biāo)準(zhǔn)的一個(gè)實(shí)現(xiàn)是 Rijndael 算法)
        /// </summary>
        /// <param name="DecryptString">待解密密文</param>
        /// <param name="DecryptKey">解密密鑰</param>
        public static string AESDecrypt(string DecryptString, string DecryptKey)
        {
            return Convert.ToBase64String(AESDecrypt(Encoding.Default.GetBytes(DecryptString), DecryptKey));
        }
        #endregion

        #region 解密字節(jié)數(shù)組
        /// <summary>
        /// AES 解密(高級(jí)加密標(biāo)準(zhǔn),是下一代的加密算法標(biāo)準(zhǔn),速度快,安全級(jí)別高,目前 AES 標(biāo)準(zhǔn)的一個(gè)實(shí)現(xiàn)是 Rijndael 算法)
        /// </summary>
        /// <param name="DecryptString">待解密密文</param>
        /// <param name="DecryptKey">解密密鑰</param>
        public static byte[] AESDecrypt(byte[] DecryptByte, string DecryptKey)
        {
            if (DecryptByte.Length == 0) { throw (new Exception("密文不得為空")); }
            if (string.IsNullOrEmpty(DecryptKey)) { throw (new Exception("密鑰不得為空")); }
            byte[] m_strDecrypt;
            byte[] m_btIV = Convert.FromBase64String("Rkb4jvUy/ye7Cd7k89QQgQ==");
            byte[] m_salt = Convert.FromBase64String("gsf4jvkyhye5/d7k8OrLgM==");
            Rijndael m_AESProvider = Rijndael.Create();
            try
            {
                MemoryStream m_stream = new MemoryStream();
                PasswordDeriveBytes pdb = new PasswordDeriveBytes(DecryptKey, m_salt);
                ICryptoTransform transform = m_AESProvider.CreateDecryptor(pdb.GetBytes(32), m_btIV);
                CryptoStream m_csstream = new CryptoStream(m_stream, transform, CryptoStreamMode.Write);
                m_csstream.Write(DecryptByte, 0, DecryptByte.Length);
                m_csstream.FlushFinalBlock();
                m_strDecrypt = m_stream.ToArray();
                m_stream.Close(); m_stream.Dispose();
                m_csstream.Close(); m_csstream.Dispose();
            }
            catch (IOException ex) { throw ex; }
            catch (CryptographicException ex) { throw ex; }
            catch (ArgumentException ex) { throw ex; }
            catch (Exception ex) { throw ex; }
            finally { m_AESProvider.Clear(); }
            return m_strDecrypt;
        }
        #endregion
        #endregion

    }
}

2、文件加密類

復(fù)制代碼 代碼如下:

using System.IO;
using System;

namespace Utils
{
    /// <summary>
    /// 文件加密類
    /// </summary>
    public class FileEncrypt
    {
        #region 變量
        /// <summary>
        /// 一次處理的明文字節(jié)數(shù)
        /// </summary>
        public static readonly int encryptSize = 10000000;
        /// <summary>
        /// 一次處理的密文字節(jié)數(shù)
        /// </summary>
        public static readonly int decryptSize = 10000016;
        #endregion

        #region 加密文件
        /// <summary>
        /// 加密文件
        /// </summary>
        public static void EncryptFile(string path, string pwd, RefreshFileProgress refreshFileProgress)
        {
            try
            {
                if (File.Exists(path + ".temp")) File.Delete(path + ".temp");
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    if (fs.Length > 0)
                    {
                        using (FileStream fsnew = new FileStream(path + ".temp", FileMode.OpenOrCreate, FileAccess.Write))
                        {
                            if (File.Exists(path + ".temp")) File.SetAttributes(path + ".temp", FileAttributes.Hidden);
                            int blockCount = ((int)fs.Length - 1) / encryptSize + 1;
                            for (int i = 0; i < blockCount; i++)
                            {
                                int size = encryptSize;
                                if (i == blockCount - 1) size = (int)(fs.Length - i * encryptSize);
                                byte[] bArr = new byte[size];
                                fs.Read(bArr, 0, size);
                                byte[] result = AES.AESEncrypt(bArr, pwd);
                                fsnew.Write(result, 0, result.Length);
                                fsnew.Flush();
                                refreshFileProgress(blockCount, i + 1); //更新進(jìn)度
                            }
                            fsnew.Close();
                            fsnew.Dispose();
                        }
                        fs.Close();
                        fs.Dispose();
                        FileAttributes fileAttr = File.GetAttributes(path);
                        File.SetAttributes(path, FileAttributes.Archive);
                        File.Delete(path);
                        File.Move(path + ".temp", path);
                        File.SetAttributes(path, fileAttr);
                    }
                }
            }
            catch (Exception ex)
            {
                File.Delete(path + ".temp");
                throw ex;
            }
        }
        #endregion

        #region 解密文件
        /// <summary>
        /// 解密文件
        /// </summary>
        public static void DecryptFile(string path, string pwd, RefreshFileProgress refreshFileProgress)
        {
            try
            {
                if (File.Exists(path + ".temp")) File.Delete(path + ".temp");
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    if (fs.Length > 0)
                    {
                        using (FileStream fsnew = new FileStream(path + ".temp", FileMode.OpenOrCreate, FileAccess.Write))
                        {
                            if (File.Exists(path + ".temp")) File.SetAttributes(path + ".temp", FileAttributes.Hidden);
                            int blockCount = ((int)fs.Length - 1) / decryptSize + 1;
                            for (int i = 0; i < blockCount; i++)
                            {
                                int size = decryptSize;
                                if (i == blockCount - 1) size = (int)(fs.Length - i * decryptSize);
                                byte[] bArr = new byte[size];
                                fs.Read(bArr, 0, size);
                                byte[] result = AES.AESDecrypt(bArr, pwd);
                                fsnew.Write(result, 0, result.Length);
                                fsnew.Flush();
                                refreshFileProgress(blockCount, i + 1); //更新進(jìn)度
                            }
                            fsnew.Close();
                            fsnew.Dispose();
                        }
                        fs.Close();
                        fs.Dispose();
                        FileAttributes fileAttr = File.GetAttributes(path);
                        File.SetAttributes(path, FileAttributes.Archive);
                        File.Delete(path);
                        File.Move(path + ".temp", path);
                        File.SetAttributes(path, fileAttr);
                    }
                }
            }
            catch (Exception ex)
            {
                File.Delete(path + ".temp");
                throw ex;
            }
        }
        #endregion

    }

    /// <summary>
    /// 更新文件加密進(jìn)度
    /// </summary>
    public delegate void RefreshFileProgress(int max, int value);

}

3、文件夾加密類

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Utils;

namespace EncryptFile.Utils
{
    /// <summary>
    /// 文件夾加密類
    /// </summary>
    public class DirectoryEncrypt
    {
        #region 加密文件夾及其子文件夾中的所有文件
        /// <summary>
        /// 加密文件夾及其子文件夾中的所有文件
        /// </summary>
        public static void EncryptDirectory(string dirPath, string pwd, RefreshDirProgress refreshDirProgress, RefreshFileProgress refreshFileProgress)
        {
            string[] filePaths = Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories);
            for (int i = 0; i < filePaths.Length; i++)
            {
                FileEncrypt.EncryptFile(filePaths[i], pwd, refreshFileProgress);
                refreshDirProgress(filePaths.Length, i + 1);
            }
        }
        #endregion

        #region 解密文件夾及其子文件夾中的所有文件
        /// <summary>
        /// 解密文件夾及其子文件夾中的所有文件
        /// </summary>
        public static void DecryptDirectory(string dirPath, string pwd, RefreshDirProgress refreshDirProgress, RefreshFileProgress refreshFileProgress)
        {
            string[] filePaths = Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories);
            for (int i = 0; i < filePaths.Length; i++)
            {
                FileEncrypt.DecryptFile(filePaths[i], pwd, refreshFileProgress);
                refreshDirProgress(filePaths.Length, i + 1);
            }
        }
        #endregion

    }

    /// <summary>
    /// 更新文件夾加密進(jìn)度
    /// </summary>
    public delegate void RefreshDirProgress(int max, int value);

}

4、跨線程訪問控制委托

復(fù)制代碼 代碼如下:

using System;
using System.Windows.Forms;

namespace Utils
{
    /// <summary>
    /// 跨線程訪問控件的委托
    /// </summary>
    public delegate void InvokeDelegate();

    /// <summary>
    /// 跨線程訪問控件類
    /// </summary>
    public class InvokeUtil
    {
        /// <summary>
        /// 跨線程訪問控件
        /// </summary>
        /// <param name="ctrl">Form對(duì)象</param>
        /// <param name="de">委托</param>
        public static void Invoke(Control ctrl, Delegate de)
        {
            if (ctrl.IsHandleCreated)
            {
                ctrl.BeginInvoke(de);
            }
        }
    }
}

5、Form1.cs文件

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Utils;
using System.Threading;
using EncryptFile.Utils;

namespace EncryptFile
{
    public partial class Form1 : Form
    {
        #region 變量
        /// <summary>
        /// 一次處理的明文字節(jié)數(shù)
        /// </summary>
        public static int encryptSize = 10000000;
        /// <summary>
        /// 一次處理的密文字節(jié)數(shù)
        /// </summary>
        public static int decryptSize = 10000016;
        #endregion

        #region 構(gòu)造函數(shù)
        public Form1()
        {
            InitializeComponent();
        }
        #endregion

        #region 加密文件
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            #region 驗(yàn)證
            if (txtPwd.Text == "")
            {
                MessageBox.Show("密碼不能為空", "提示");
                return;
            }

            if (txtPwdCfm.Text == "")
            {
                MessageBox.Show("確認(rèn)密碼不能為空", "提示");
                return;
            }

            if (txtPwdCfm.Text != txtPwd.Text)
            {
                MessageBox.Show("兩次輸入的密碼不相同", "提示");
                return;
            }
            #endregion

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(delegate(object obj)
                {
                    try
                    {
                        InvokeDelegate invokeDelegate = delegate()
                        {
                            pbFile.Value = 0;
                            lblProgressFile.Text = "0%";
                            pbDir.Visible = false;
                            lblProgressDir.Visible = false;
                            pbFile.Visible = false;
                            lblProgressFile.Visible = false;
                            lblShowPath.Text = "文件:" + openFileDialog1.FileName;
                            lblShowPath.Visible = true;
                            DisableBtns();
                        };
                        InvokeUtil.Invoke(this, invokeDelegate);
                        DateTime t1 = DateTime.Now;
                        FileEncrypt.EncryptFile(openFileDialog1.FileName, txtPwd.Text, RefreshFileProgress);
                        DateTime t2 = DateTime.Now;
                        string t = t2.Subtract(t1).TotalSeconds.ToString("0.00");
                        if (MessageBox.Show("加密成功,耗時(shí)" + t + "秒", "提示") == DialogResult.OK)
                        {
                            invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (MessageBox.Show("加密失敗:" + ex.Message, "提示") == DialogResult.OK)
                        {
                            InvokeDelegate invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                }));
                thread.Start();
            }
        }
        #endregion

        #region 解密文件
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            #region 驗(yàn)證
            if (txtPwd.Text == "")
            {
                MessageBox.Show("密碼不能為空", "提示");
                return;
            }
            #endregion

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(delegate(object obj)
                {
                    try
                    {
                        InvokeDelegate invokeDelegate = delegate()
                        {
                            pbFile.Value = 0;
                            lblProgressFile.Text = "0%";
                            pbDir.Visible = false;
                            lblProgressDir.Visible = false;
                            pbFile.Visible = false;
                            lblProgressFile.Visible = false;
                            lblShowPath.Text = "文件:" + openFileDialog1.FileName;
                            lblShowPath.Visible = true;
                            DisableBtns();
                        };
                        InvokeUtil.Invoke(this, invokeDelegate);
                        DateTime t1 = DateTime.Now;
                        FileEncrypt.DecryptFile(openFileDialog1.FileName, txtPwd.Text, RefreshFileProgress);
                        DateTime t2 = DateTime.Now;
                        string t = t2.Subtract(t1).TotalSeconds.ToString("0.00");
                        if (MessageBox.Show("解密成功,耗時(shí)" + t + "秒", "提示") == DialogResult.OK)
                        {
                            invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (MessageBox.Show("解密失?。? + ex.Message, "提示") == DialogResult.OK)
                        {
                            InvokeDelegate invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                }));
                thread.Start();
            }
        }
        #endregion

        #region 文件夾加密
        private void btnEncryptDir_Click(object sender, EventArgs e)
        {
            #region 驗(yàn)證
            if (txtPwd.Text == "")
            {
                MessageBox.Show("密碼不能為空", "提示");
                return;
            }

            if (txtPwdCfm.Text == "")
            {
                MessageBox.Show("確認(rèn)密碼不能為空", "提示");
                return;
            }

            if (txtPwdCfm.Text != txtPwd.Text)
            {
                MessageBox.Show("兩次輸入的密碼不相同", "提示");
                return;
            }
            #endregion

            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                if (MessageBox.Show(string.Format("確定加密文件夾{0}?", folderBrowserDialog1.SelectedPath),
                    "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }

                Thread thread = new Thread(new ParameterizedThreadStart(delegate(object obj)
                {
                    try
                    {
                        InvokeDelegate invokeDelegate = delegate()
                        {
                            pbDir.Value = 0;
                            lblProgressDir.Text = "0%";
                            pbFile.Value = 0;
                            lblProgressFile.Text = "0%";
                            pbDir.Visible = true;
                            lblProgressDir.Visible = true;
                            pbFile.Visible = false;
                            lblProgressFile.Visible = false;
                            lblShowPath.Text = "文件夾:" + folderBrowserDialog1.SelectedPath;
                            lblShowPath.Visible = true;
                            DisableBtns();
                        };
                        InvokeUtil.Invoke(this, invokeDelegate);
                        DateTime t1 = DateTime.Now;
                        DirectoryEncrypt.EncryptDirectory(folderBrowserDialog1.SelectedPath, txtPwd.Text, RefreshDirProgress, RefreshFileProgress);
                        DateTime t2 = DateTime.Now;
                        string t = t2.Subtract(t1).TotalSeconds.ToString("0.00");
                        if (MessageBox.Show("加密成功,耗時(shí)" + t + "秒", "提示") == DialogResult.OK)
                        {
                            invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (MessageBox.Show("加密失敗:" + ex.Message, "提示") == DialogResult.OK)
                        {
                            InvokeDelegate invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                }));
                thread.Start();
            }
        }
        #endregion

        #region 文件夾解密
        private void btnDecryptDir_Click(object sender, EventArgs e)
        {
            #region 驗(yàn)證
            if (txtPwd.Text == "")
            {
                MessageBox.Show("密碼不能為空", "提示");
                return;
            }
            #endregion

            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                if (MessageBox.Show(string.Format("確定解密文件夾{0}?", folderBrowserDialog1.SelectedPath),
                    "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }

                Thread thread = new Thread(new ParameterizedThreadStart(delegate(object obj)
                {
                    try
                    {
                        InvokeDelegate invokeDelegate = delegate()
                        {
                            pbDir.Value = 0;
                            lblProgressDir.Text = "0%";
                            pbFile.Value = 0;
                            lblProgressFile.Text = "0%";
                            pbDir.Visible = true;
                            lblProgressFile.Visible = true;
                            pbFile.Visible = false;
                            lblProgressFile.Visible = false;
                            lblShowPath.Text = "文件夾:" + folderBrowserDialog1.SelectedPath;
                            lblShowPath.Visible = true;
                            DisableBtns();
                        };
                        InvokeUtil.Invoke(this, invokeDelegate);
                        DateTime t1 = DateTime.Now;
                        DirectoryEncrypt.DecryptDirectory(folderBrowserDialog1.SelectedPath, txtPwd.Text, RefreshDirProgress, RefreshFileProgress);
                        DateTime t2 = DateTime.Now;
                        string t = t2.Subtract(t1).TotalSeconds.ToString("0.00");
                        if (MessageBox.Show("解密成功,耗時(shí)" + t + "秒", "提示") == DialogResult.OK)
                        {
                            invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (MessageBox.Show("解密失?。? + ex.Message, "提示") == DialogResult.OK)
                        {
                            InvokeDelegate invokeDelegate = delegate()
                            {
                                EnableBtns();
                            };
                            InvokeUtil.Invoke(this, invokeDelegate);
                        }
                    }
                }));
                thread.Start();
            }
        }
        #endregion

        #region 更新文件加密進(jìn)度
        /// <summary>
        /// 更新文件加密進(jìn)度
        /// </summary>
        public void RefreshFileProgress(int max, int value)
        {
            InvokeDelegate invokeDelegate = delegate()
            {
                if (max > 1)
                {
                    pbFile.Visible = true;
                    lblProgressFile.Visible = true;
                }
                else
                {
                    pbFile.Visible = false;
                    lblProgressFile.Visible = false;
                }
                pbFile.Maximum = max;
                pbFile.Value = value;
                lblProgressFile.Text = value * 100 / max + "%";
            };
            InvokeUtil.Invoke(this, invokeDelegate);
        }
        #endregion

        #region 更新文件夾加密進(jìn)度
        /// <summary>
        /// 更新文件夾加密進(jìn)度
        /// </summary>
        public void RefreshDirProgress(int max, int value)
        {
            InvokeDelegate invokeDelegate = delegate()
            {
                pbDir.Maximum = max;
                pbDir.Value = value;
                lblProgressDir.Text = value * 100 / max + "%";
            };
            InvokeUtil.Invoke(this, invokeDelegate);
        }
        #endregion

        #region 顯示密碼
        private void cbxShowPwd_CheckedChanged(object sender, EventArgs e)
        {
            if (cbxShowPwd.Checked)
            {
                txtPwd.PasswordChar = default(char);
                txtPwdCfm.PasswordChar = default(char);
            }
            else
            {
                txtPwd.PasswordChar = '*';
                txtPwdCfm.PasswordChar = '*';
            }
        }
        #endregion

        #region 關(guān)閉窗體事件
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (progressPanel.Visible)
            {
                MessageBox.Show("正在處理文件,請(qǐng)等待…", "提示");
                e.Cancel = true;
            }
        }
        #endregion

        #region 控制按鈕狀態(tài)
        /// <summary>
        /// 禁用按鈕
        /// </summary>
        public void DisableBtns()
        {
            progressPanel.Visible = true;
            btnEncrypt.Enabled = false;
            btnDecrypt.Enabled = false;
            btnEncryptDir.Enabled = false;
            btnDecryptDir.Enabled = false;
        }
        /// <summary>
        /// 啟用按鈕
        /// </summary>
        public void EnableBtns()
        {
            lblShowPath.Visible = false;
            progressPanel.Visible = false;
            btnEncrypt.Enabled = true;
            btnDecrypt.Enabled = true;
            btnEncryptDir.Enabled = true;
            btnDecryptDir.Enabled = true;
        }
        #endregion

    }
}

完整實(shí)例代碼點(diǎn)擊此處本站下載。

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • Unity利用材質(zhì)自發(fā)光實(shí)現(xiàn)物體閃爍

    Unity利用材質(zhì)自發(fā)光實(shí)現(xiàn)物體閃爍

    這篇文章主要為大家詳細(xì)介紹了Unity利用材質(zhì)自發(fā)光實(shí)現(xiàn)物體閃爍,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-04-04
  • C#高效反射調(diào)用方法類實(shí)例詳解

    C#高效反射調(diào)用方法類實(shí)例詳解

    在本篇文章中小編給大家分享的是關(guān)于C#高效反射調(diào)用方法類的相關(guān)實(shí)例內(nèi)容,有興趣的朋友們學(xué)習(xí)下。
    2019-07-07
  • LZW數(shù)據(jù)壓縮算法的原理分析

    LZW數(shù)據(jù)壓縮算法的原理分析

    我希望通過本文的介紹,能給那些目前不太了解lzw算法和該算法在gif圖像中應(yīng)用,但渴望了解它的人一些啟發(fā)和幫助。拋磚引玉而已,更希望兄弟們提出寶貴的意見。
    2016-06-06
  • C#畢業(yè)設(shè)計(jì)之Winform零壓健身房管理系統(tǒng)

    C#畢業(yè)設(shè)計(jì)之Winform零壓健身房管理系統(tǒng)

    本文介紹了個(gè)人的《零壓健身房管理系統(tǒng)(扁平化)》的基本流程和功能點(diǎn)的介紹,虛心接受各位的意見,歡迎在提出寶貴的意見,大家一起探討學(xué)習(xí)
    2021-09-09
  • C#操作INI文件的方法詳解

    C#操作INI文件的方法詳解

    INI文件全稱是Initialization File的縮寫,即初始化文件,是windows系統(tǒng)的系統(tǒng)配置文件所采用的存儲(chǔ)格式,統(tǒng)管windows的各項(xiàng)配置。本文介紹了C#操作INI文件的方法,需要的可以參考一下
    2022-10-10
  • C# Record構(gòu)造函數(shù)的行為更改詳解

    C# Record構(gòu)造函數(shù)的行為更改詳解

    C# 9 中的record類型是僅具有只讀屬性的輕量級(jí)、不可變數(shù)據(jù)類型(或輕量級(jí)類),下面這篇文章主要給大家介紹了關(guān)于C# Record構(gòu)造函數(shù)的行為更改的相關(guān)資料,需要的朋友可以參考下
    2021-08-08
  • C#使用二維數(shù)組模擬斗地主

    C#使用二維數(shù)組模擬斗地主

    這篇文章主要介紹了C#使用二維數(shù)組模擬斗地主的方法,通過C#的二維數(shù)組簡單實(shí)現(xiàn)撲克隨機(jī)發(fā)牌的功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-04-04
  • C#實(shí)現(xiàn)創(chuàng)建標(biāo)簽PDF文件的示例代碼

    C#實(shí)現(xiàn)創(chuàng)建標(biāo)簽PDF文件的示例代碼

    標(biāo)簽PDF文件包含描述文檔結(jié)構(gòu)和各種文檔元素順序的元數(shù)據(jù),是一種包含后端提供的可訪問標(biāo)記,管理閱讀順序和文檔內(nèi)容表示的邏輯結(jié)構(gòu)的PDF文件。本文將用C#實(shí)現(xiàn)創(chuàng)建標(biāo)簽PDF文件,需要的可以參考一下
    2022-08-08
  • C#自動(dòng)判斷Excel版本使用不同的連接字符串

    C#自動(dòng)判斷Excel版本使用不同的連接字符串

    這篇文章主要介紹了C#自動(dòng)判斷Excel版本使用不同的連接字符串,本文重點(diǎn)在不同版本的連接字符串介紹,需要的朋友可以參考下
    2015-06-06
  • C#程序提示“正由另一進(jìn)程使用,因此該進(jìn)程無法訪問該文件”的解決辦法

    C#程序提示“正由另一進(jìn)程使用,因此該進(jìn)程無法訪問該文件”的解決辦法

    這篇文章主要介紹了C#程序提示“正由另一進(jìn)程使用,因此該進(jìn)程無法訪問該文件”的解決辦法,本文通過改寫程序代碼實(shí)現(xiàn)解決這個(gè)問題,需要的朋友可以參考下
    2015-06-06

最新評(píng)論