Seeing as though this is probably one of the only sites where I'll get some straight answers, I decided to bring this here.
The Problem:
What this program I'm working on does is it recursively checks folders within a selected directory for files with a specific file header (so yeah, I open the file with EndianIO, read the first 4 bytes, etc.), so whenever I hit a file I can't access - that's fine, the loop keeps on going, but whenever I hit a DIRECTORY I can't seem to access... that breaks the entire operation.
The Goal:
Make it so that when it hits an inaccessible directory, it doesn't break the operation.
Since I really haven't worked with directories or directory attributes before, would anyone have any ideas?
Error example:
error1.PNG (63.92K)
Number of downloads: 14
Code I'm working with:
try
{
string[] folderlist = System.IO.Directory.GetDirectories(KidCuDi, "*", System.IO.SearchOption.AllDirectories);
ListViewItem lvi;
ListViewItem.ListViewSubItem lvsi;
foreach (string yeah in Directory.GetDirectories(KidCuDi))
{
DirectoryInfo yee = new DirectoryInfo(yeah);
foreach (FileInfo file2 in yee.GetFiles())
{
*rest of my code goes in here*Help is appreciated, thanks in advanced.
Edit: It doesn't break each time it reaches an inaccessible file, it breaks after 7 errors are thrown (there are two voids going on, one gets the files from the directory chosen, the other gets the files within each subdirectory)



Back to top
MultiQuote