C#文件加密方法汇总

 更新时间:2020年6月25日 11:33  点击:2268

本文实例汇总了C#文件加密方法。分享给大家供大家参考。具体实现方法如下:

1、AES加密类

复制代码 代码如下:

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

namespace Utils
{
    /// <summary>
    /// AES加密解密
    /// </summary>
    public class AES
    {
        #region 加密
        #region 加密字符串
        /// <summary>
        /// AES 加密(高级加密标准,是下一代的加密算法标准,速度快,安全级别高,目前 AES 标准的一个实现是 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 加密字节数组
        /// <summary>
        /// AES 加密(高级加密标准,是下一代的加密算法标准,速度快,安全级别高,目前 AES 标准的一个实现是 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 解密(高级加密标准,是下一代的加密算法标准,速度快,安全级别高,目前 AES 标准的一个实现是 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 解密字节数组
        /// <summary>
        /// AES 解密(高级加密标准,是下一代的加密算法标准,速度快,安全级别高,目前 AES 标准的一个实现是 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、文件加密类

复制代码 代码如下:

using System.IO;
using System;

namespace Utils
{
    /// <summary>
    /// 文件加密类
    /// </summary>
    public class FileEncrypt
    {
        #region 变量
        /// <summary>
        /// 一次处理的明文字节数
        /// </summary>
        public static readonly int encryptSize = 10000000;
        /// <summary>
        /// 一次处理的密文字节数
        /// </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); //更新进度
                            }
                            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); //更新进度
                            }
                            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>
    /// 更新文件加密进度
    /// </summary>
    public delegate void RefreshFileProgress(int max, int value);

}

3、文件夹加密类

复制代码 代码如下:

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>
    /// 更新文件夹加密进度
    /// </summary>
    public delegate void RefreshDirProgress(int max, int value);

}

4、跨线程访问控制委托

复制代码 代码如下:

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对象</param>
        /// <param name="de">委托</param>
        public static void Invoke(Control ctrl, Delegate de)
        {
            if (ctrl.IsHandleCreated)
            {
                ctrl.BeginInvoke(de);
            }
        }
    }
}

5、Form1.cs文件

复制代码 代码如下:

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>
        /// 一次处理的明文字节数
        /// </summary>
        public static int encryptSize = 10000000;
        /// <summary>
        /// 一次处理的密文字节数
        /// </summary>
        public static int decryptSize = 10000016;
        #endregion

        #region 构造函数
        public Form1()
        {
            InitializeComponent();
        }
        #endregion

        #region 加密文件
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            #region 验证
            if (txtPwd.Text == "")
            {
                MessageBox.Show("密码不能为空", "提示");
                return;
            }

            if (txtPwdCfm.Text == "")
            {
                MessageBox.Show("确认密码不能为空", "提示");
                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("加密成功,耗时" + 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 验证
            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("解密成功,耗时" + 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 验证
            if (txtPwd.Text == "")
            {
                MessageBox.Show("密码不能为空", "提示");
                return;
            }

            if (txtPwdCfm.Text == "")
            {
                MessageBox.Show("确认密码不能为空", "提示");
                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("加密成功,耗时" + 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 验证
            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("解密成功,耗时" + 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 更新文件加密进度
        /// <summary>
        /// 更新文件加密进度
        /// </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 更新文件夹加密进度
        /// <summary>
        /// 更新文件夹加密进度
        /// </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 关闭窗体事件
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (progressPanel.Visible)
            {
                MessageBox.Show("正在处理文件,请等待…", "提示");
                e.Cancel = true;
            }
        }
        #endregion

        #region 控制按钮状态
        /// <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

    }
}

完整实例代码点击此处本站下载。

希望本文所述对大家的C#程序设计有所帮助。

[!--infotagslink--]

相关文章

  • C#实现简单的登录界面

    我们在使用C#做项目的时候,基本上都需要制作登录界面,那么今天我们就来一步步看看,如果简单的实现登录界面呢,本文给出2个例子,由简入难,希望大家能够喜欢。...2020-06-25
  • 浅谈C# 字段和属性

    这篇文章主要介绍了C# 字段和属性的的相关资料,文中示例代码非常详细,供大家参考和学习,感兴趣的朋友可以了解下...2020-11-03
  • C#中截取字符串的的基本方法详解

    这篇文章主要介绍了C#中截取字符串的的基本方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-11-03
  • C#实现简单的Http请求实例

    这篇文章主要介绍了C#实现简单的Http请求的方法,以实例形式较为详细的分析了C#实现Http请求的具体方法,需要的朋友可以参考下...2020-06-25
  • C#连接SQL数据库和查询数据功能的操作技巧

    本文给大家分享C#连接SQL数据库和查询数据功能的操作技巧,本文通过图文并茂的形式给大家介绍的非常详细,需要的朋友参考下吧...2021-05-17
  • C#中new的几种用法详解

    本文主要介绍了C#中new的几种用法,具有很好的参考价值,下面跟着小编一起来看下吧...2020-06-25
  • 使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)

    这篇文章主要介绍了使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • C#开发Windows窗体应用程序的简单操作步骤

    这篇文章主要介绍了C#开发Windows窗体应用程序的简单操作步骤,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-04-12
  • C#从数据库读取图片并保存的两种方法

    这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
  • 图解PHP使用Zend Guard 6.0加密方法教程

    有时为了网站安全和版权问题,会对自己写的php源码进行加密,在php加密技术上最常用的是zend公司的zend guard 加密软件,现在我们来图文讲解一下。 下面就简单说说如何...2016-11-25
  • C#和JavaScript实现交互的方法

    最近做一个小项目不可避免的需要前端脚本与后台进行交互。由于是在asp.net中实现,故问题演化成asp.net中jiavascript与后台c#如何进行交互。...2020-06-25
  • C++调用C#的DLL程序实现方法

    本文通过例子,讲述了C++调用C#的DLL程序的方法,作出了以下总结,下面就让我们一起来学习吧。...2020-06-25
  • 轻松学习C#的基础入门

    轻松学习C#的基础入门,了解C#最基本的知识点,C#是一种简洁的,类型安全的一种完全面向对象的开发语言,是Microsoft专门基于.NET Framework平台开发的而量身定做的高级程序设计语言,需要的朋友可以参考下...2020-06-25
  • C#变量命名规则小结

    本文主要介绍了C#变量命名规则小结,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-09-09
  • C#绘制曲线图的方法

    这篇文章主要介绍了C#绘制曲线图的方法,以完整实例形式较为详细的分析了C#进行曲线绘制的具体步骤与相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
  • C# 中如何取绝对值函数

    本文主要介绍了C# 中取绝对值的函数。具有很好的参考价值。下面跟着小编一起来看下吧...2020-06-25
  • c#自带缓存使用方法 c#移除清理缓存

    这篇文章主要介绍了c#自带缓存使用方法,包括获取数据缓存、设置数据缓存、移除指定数据缓存等方法,需要的朋友可以参考下...2020-06-25
  • c#中(&&,||)与(&,|)的区别详解

    这篇文章主要介绍了c#中(&&,||)与(&,|)的区别详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-25
  • 经典实例讲解C#递归算法

    这篇文章主要用实例讲解C#递归算法的概念以及用法,文中代码非常详细,帮助大家更好的参考和学习,感兴趣的朋友可以了解下...2020-06-25
  • C#学习笔记- 随机函数Random()的用法详解

    下面小编就为大家带来一篇C#学习笔记- 随机函数Random()的用法详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25