First problem: don't call
GetFiles
twice. If you want the number of files that were returned, look at the
Length
property on the array you've already stored.
Second problem: the
Length
property doesn't have any arguments. Which means your call to
.Length(CurrentDir)
must be calling an extension method that you've created. Since you haven't shown us that extension method, we can't tell you why it's not returning the correct value.
Third problem: nobody here has access to your disk. We cannot guess why you are not seeing all of the files you expect to see.
Try using:
string[] files = Directory.GetFiles(CurrentDirectory);
for (int i = 0; i < files.Length; i++)
{
MessageBox.Show(files[i]);
}
or:
string[] files = Directory.GetFiles(CurrentDirectory);
foreach (string file in files)
{
MessageBox.Show(file);
}
or even:
foreach (string file in Directory.EnumerateFiles(CurrentDirectory))
{
MessageBox.Show(file);
}