here is my code,
foreach (DataGridViewRow dr in datagridscanedfiles.Rows)
{
for (int i = datagridscanedfiles.Rows.Count - 1; i >= 0; i--)
{
if ((bool)datagridscanedfiles.Rows[0].Cells[0].Value)
{
DirectoryInfo directoryInfo = new DirectoryInfo(@"D:\mohan\MACRO WINDOWS\MACRO WINDOWS\MACRO WINDOWS\Scan\");
foreach (var file in directoryInfo.GetFiles("*.*", SearchOption.AllDirectories))
{
FileInfo file=new FileInfo (@"D:\mohan\MACRO WINDOWS\MACRO WINDOWS\MACRO WINDOWS\Scan\");
file.Delete();
}
scanfile.Clear();
datagridscanedfiles.Rows.RemoveAt(i);
picboxscan.Image = null;
}
}
}
}
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shankar MPosted Dec 15, 2013, 11:55 PM
Why are you looping through the Files to Delete Files. ?
You can delete the DataGridView row using :
datagridView1.Rows.RemoveAt(Index);
The Index has to be the rowIndex value (For Ex: 0 - To remove 0th row)
To Delete the File From Directory you can use:
File.Delete(DirectoryName);
Thanks, Shankar M