【发布时间】:2013-11-29 06:22:12
【问题描述】:
如何从特定单元格的 datagridview 图像列中删除图像,实际上我必须从特定文件夹的目录中删除图像,但它给出了另一个进程使用的图像错误,所以请帮助我
filefullPath = Application.StartupPath + "\\PatientDocuments\\" + patId + "\\" + imge;
if (e.ColumnIndex == 5)
{
DialogResult mesg = MessageBox.Show("Are You Sure Do You Want To Delete?", "Delete", MessageBoxButtons.YesNo);
if (mesg == DialogResult.Yes)
{
BL_db.ImgId = imgeid;
int i = Convert.ToInt32(dgvImage.SelectedRows[0].Index.ToString());
dgvImage.Rows.RemoveAt(i);
BL.Delete_PatientImage(BL_db);
//DataGridViewImageColumn imgcolumn = new DataGridViewImageColumn();
//imgcolumn.Dispose();
//DataGridViewImageCell imgcell = new DataGridViewImageCell();
// imgcell = (DataGridViewImageCell)dgvImage.Rows[dgvImage.CurrentRow.Index].Cells[2];
//imgcell.Dispose();
//---------for delete file from directory-----------------------
string[] arr1 = Directory.GetFiles(Application.StartupPath + "\\PatientDocuments\\" + patId, "*.jpg");
foreach (string filePath in arr1)
{
if (filePath.Contains(".jpg"))
File.Delete(filePath);
}
//-------------------------------------------------![enter image description here][1]`
}
}
【问题讨论】:
标签: c#-4.0