Как мы можем зашифровать файлы при проверке выбранного файла в представлении 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();
}
}