小编Bur*_*855的帖子

使用带有进度报告的C#提取ZipFile

任何人都可以告诉我是否有可能(并举例说明)如何有一个进度条(如果可能的话还有状态标签),显示使用"ZipFile"提取的ZIP文件的进度(Ionic.zip,http ://dotnetzip.codeplex.com/)?

我的WinForm在将我选择的路径中的ZIP文件提取到新路径方面做得非常出色,完全不用担心使用文本框和浏览按钮以及所有爵士乐......但唯一的问题是我在此期间无法在我的表单上使用任何内容它好像已经冻结了,但它只是因为它在后台解压缩ZIP文件.

ZIP文件是一个大文件,我想通过添加和显示如何使用准确的ETA进行解压缩进度条来减少对正在发生的事情的混淆.

当然这是可能的,我只是无法弄清楚如何在C#WinForms中做到这一点,我在网络上有一个相当不错的外观,但没有真正能够遇到一个我能找到适合我的例子.

这是我所拥有的一个粗略的例子:

private void button1_Click(object sender, EventArgs e)
{
    var ROBOT0007 = textBox1.Text + @"\" + "ROBOT0007"; //ROBOT0007 folder
    var ROBOT_INSTALL = textBox1.Text + @"\" + "911" + @"\" + "files"; //ROBOT0007/911/files
    var ROBOT_INSTALL_SPECIAL = ROBOT_INSTALL + @"\" + "special.rar";  //ROBOT0007/911/files/special.rar

    //If the path has text...
    if (textBox1.TextLength > 0)
    {
        //if the subfolder doesn't exist then make it.
        if (!Directory.Exists(ROBOT0007))
        {
            Directory.CreateDirectory(ROBOT0007);
        }

        //if the textbox directory exists
        if (Directory.Exists(ROBOT0007))
        {
            using (ZipFile …
Run Code Online (Sandbox Code Playgroud)

c# winforms

1
推荐指数
1
解决办法
9152
查看次数

通过filedialog打开一个可执行文件这会出错 - 为什么?

有谁知道为什么以下将打开Kool.exe但Kool.exe无法加载其所有文件,除非我将当前项目debug/project.exe放入与它试图打开的Kool.exe相同的文件夹中?

private void button1_Click(object sender, EventArgs e)
{
    OpenFileDialog openF1 = new OpenFileDialog();

    openF1.InitialDirectory = @"C:\";
    openF1.Title = "Browse for Kool.exe...";
    openF1.CheckFileExists = true;
    openF1.CheckPathExists = true;
    openF1.DefaultExt = "exe";
    openF1.FileName = "Kool";
    openF1.Filter = "Kool (*.exe)|*.exe|All Files(*.*)|*.*";
    openF1.FilterIndex = 2;
    openF1.RestoreDirectory = true;
    openF1.ReadOnlyChecked = true;
    openF1.ShowReadOnly = true;

    if (openF1.ShowDialog() == DialogResult.OK)
    {
        Process[] pname = Process.GetProcessesByName(openF1.FileName);
        if (pname.Length == 0)
        {
            Process.Start(openF1.FileName);
            this.Close();
        }
        else
        {
            MessageBox.Show("Kool is already running.", "Patch: Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
        }
    } …
Run Code Online (Sandbox Code Playgroud)

c# winforms

0
推荐指数
1
解决办法
814
查看次数

带密码的C#WinForms加密

我有一个我正在研究的WinForms应用程序,基本上我现在使用表单/列表框/文本框创建了一些数据,然后使用ecryption密码将该数据加密为文本文件.

我这一切都工作顺利和令人敬畏,我只是想知道使用这种方法是否安全,因为它是安全的具有这种加密方法的文本文件(TripleDES算法):

        //Encryption Method
        public string EncryptString(string Message, string Passphrase)
    {
        byte[] Results;
        System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();
        MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
        byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
        TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
        TDESAlgorithm.Key = TDESKey;
        TDESAlgorithm.Mode = CipherMode.ECB;
        TDESAlgorithm.Padding = PaddingMode.PKCS7;
        byte[] DataToEncrypt = UTF8.GetBytes(Message);
        try
        {
            ICryptoTransform Encryptor = TDESAlgorithm.CreateEncryptor();
            Results = Encryptor.TransformFinalBlock(DataToEncrypt, 0, DataToEncrypt.Length);
        }
        finally
        {
            TDESAlgorithm.Clear();
            HashProvider.Clear();
        }
        return Convert.ToBase64String(Results);
    }


    //Decryption Method
    public string DecryptString(string Message, string Passphrase)
    {
        byte[] Results;
        System.Text.UTF8Encoding UTF8 = new …
Run Code Online (Sandbox Code Playgroud)

c# encryption winforms

-1
推荐指数
1
解决办法
826
查看次数

标签 统计

c# ×3

winforms ×3

encryption ×1