我们如何在datagrid视图中检查选定文件时加密文件。 [英] How can we encrypt files on checking selected file in datagrid view.

查看:85
本文介绍了我们如何在datagrid视图中检查选定文件时加密文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi ,

Any one can give me a example how can we encyrpt selcted files in gridview and save them in certain folder, i have tried below code but cant encrypt selected file.

What I have tried:

<pre>void BtnUploadClick(object sender, EventArgs e)
        {
            //Sample on Sun 01.12.2014 At 09.13 AM
            string locationToCreateFolder = "E://";
            string folderName = "Upload";
            string date = DateTime.Now.ToString("ddd MM.dd.yyyy");
            string time = DateTime.Now.ToString("HH.mm tt");
            string format = "{0} on {1} At {2}";
            folderName = string.Format(format, textBox1.Text, date, time);
            Directory.CreateDirectory(locationToCreateFolder + "Upload");
            MessageBox.Show("done");
            int CheckBoxRowCounter = 0;
            // Encrypt_and_decrypt.AES a  = new AES();
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value))
                {
                    CheckBoxRowCounter++;
                }
            }
             if (CheckBoxRowCounter > 0)
            {
                if (folderBrowserDlg.ShowDialog() == DialogResult.OK)
                {
                    String folderPath = folderBrowserDlg.SelectedPath;
                    for (int i = 0; i < dataGridView1.RowCount; i++)
                    {
                        if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value))
                        {
                            string SourceFilePath = dataGridView1.Rows[i].Cells[1].Value.ToString();
                            string SourceFileName = new System.IO.FileInfo(SourceFilePath).Name;
                            string TargetFilePath = folderPath + @"\" + SourceFileName;
                            if (!System.IO.File.Exists(TargetFilePath))
                            {
                                if (System.IO.File.Exists(SourceFilePath))
                                {
                                    System.IO.File.Move(SourceFilePath, TargetFilePath);
                                }
                            }
                            //string Hidkey = dataGridView1[0,2].Value.ToString();
                        //    dataGridView1[0,1].Value= a.EncryptFile("E:\\ on Fri 05.11.2018 At 08.59 AM","E:\\encrypt","Hidkey");
                        }
                    }
                    MessageBox.Show("Selected Files Moved.Refreshing Grid...");
                    FillGridView();
                }
            }

推荐答案

这是你对这个问题的第二个转发,你得到了一些建议。也许你应该试试其中的一些。
This is your second repost of this question and you have been given a number of suggestions. Maybe you should try some of them.


.NET中有一个完整的Cryptography命名空间。要加密文件,您需要编写代码来加密它们,但尚未加密。为什么你会有一个Web应用程序在客户端上获取路径然后迭代服务器上的该文件夹?如果你想编写代码让人们管理你的文件系统,你需要告诉他们它是什么
There's a whole Cryptography namespace in .NET. To encrypt your files, you need to write code to encrypt them, which you have not, yet. Why would you have a web app that takes a path on the client and then iterates over that folder on the server? If you want to write code to let people manage your file system, you'll need to tell them what it is


我非常感谢你的建议,我有我的解决方案。但我需要一个建议

我在按钮点击时写了一些belw代码,当我点击按钮时它创建了一个文件夹,在我的原始帖子中我通过folderbrowser工具上传文件,现在我需要dirctly上传文件使用它我该怎么办。

I all thanks for your suggestions, I have got my solution.but I need one suggestion
I have written belw code on button click where it creates a folder when i click on button, and in my orginal post i upload files through folderbrowser tool, now i need to uplaod files dirctly with out using it how can i do it.
void BtnUploadClick(object sender, EventArgs e)
		{
			 var folder =Directory.CreateDirectory("E:\\UPLOAD");



}


}


这篇关于我们如何在datagrid视图中检查选定文件时加密文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆