I am trying count total number of files in all the sub folder of a given path. I am using recursive function call. What could be the reason?
Code:
int iCount =0;
getFileCount(_dirPath, out iCount);
private void getFileCount(string _path, out int iCount )
{
try
{
// gives error :Use of unassigned out parameter 'iCount' RED Underline
iCount += Directory.GetFiles(_path).Length;
foreach (string _dirPath in Directory.GetDirectories(_path))
getFileCount(_dirPath, out iCount);
}
catch { }
}