Reputation: 89
I'm using 2008 and am unable to use the EnumerateFiles
class.
Any folder beyond the root level are essentially ignored when attempting to sum the files within listed network path. Here's my code:
public void getLeverageServer(string Server)
{
int Inp = 0;
int Out = 0;
int Ex = 0;
string output = "\\\\" + Server + "\\F\\Output";
string input = "\\\\" + Server + "\\F\\Input";
string exceptions = "\\\\" + Server + "\\F\\Exceptions";
string[] pathIn = Directory.GetFiles(input);
string[] pathOut = Directory.GetFiles(output);
string[] pathExceptions = Directory.GetFiles(exceptions);
foreach (string element in pathIn)
{
Inp++;
}
foreach (string element in pathOut)
{
Out++;
}
foreach (string element in pathExceptions)
{
Ex++;
}
txtLevInp.Text = Convert.ToString(Inp);
txtLevOut.Text = Convert.ToString(Out);
txtLevExc.Text = Convert.ToString(Ex);
txtLevTotal.Text = Convert.ToString(Out + Ex);
}
Upvotes: 1
Views: 60
Reputation: 216293
You need a different overload of Directory.GetFiles
string[] pathIn = Directory.GetFiles(input, "*.*", SearchOption.AllDirectories);
And you don't need to count the files found. Just read the value of the property Length
of the returned array....
txtLevInp.Text = pathIn.Length;
Upvotes: 1