I have code that generates a listview directory of my computer. When I open the C directory it shows $RECYCLE.Bin. Is there anyway to have it where it doesn’t show these files?
foreach (string dir in folders)
{
dirData[0] = dir.ToString();
dirData[1] = dir.Length.ToString();
dirData[2] = File.GetLastAccessTime(dir).ToString();
ListViewItem lv = new ListViewItem(dirData, imageList1.Images.Count - 1);
lv.Tag = dir;
imageList1.Images.Add(BlackFox.Win32.Icons.IconFromExtensionShell(".*", BlackFox.Win32.Icons.SystemIconSize.Small).ToBitmap());
listView1.SmallImageList = imageList1;
listView1.Items.Add(lv);
}
Something like this should work
Let me expand on the answer as some people may find it difficult to understand, This will ignore
SystemHiddendirectrories.ie:
"C:\\$Recycle.Bin""C:\\Documents and Settings""C:\\System Volume Information"If you want to ignore all hidden directories you can simply omit the
FileAttributes.Systemattribute from the linq statement but this would result in losing directories likeProgramDatain yourListViewwhich I’m not sure you want.