I am trying to read all of the files under a specified starting directory. The code I am using is:
ThisPathItems.AddRange(Directory.GetFiles(lblIPPath.Text, "*.*", SearchOption.AllDirectories));
foreach (string pn in ThisPathItems)
{
strCDFPathName = Path.GetDirectoryName(pn); // directory name without file name
}
The trouble is, when I run this on the root directory, it tries to process the "System Volume Information" directory, and it crashes.
I have looked on Google for an example of how to handle this, but I can find nothing. One part said to use DirectoryInfo.GetFiles instead, but there were no examples, so I came up empty.
Does anyone know how I can get out of this bind?
Thanks much!
Dave
ThisPathItems.AddRange(Directory.GetFiles(lblIPPath.Text, "*.*", SearchOption.AllDirectories));
foreach (string pn in ThisPathItems)
{
strCDFPathName = Path.GetDirectoryName(pn); // directory name without file name
}
The trouble is, when I run this on the root directory, it tries to process the "System Volume Information" directory, and it crashes.
I have looked on Google for an example of how to handle this, but I can find nothing. One part said to use DirectoryInfo.GetFiles instead, but there were no examples, so I came up empty.
Does anyone know how I can get out of this bind?
Thanks much!
Dave