private int dReturn, fReturn = 0;
public Maker()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (fd.ShowDialog() != DialogResult.OK) { return; }
listView1.Items.Clear();
dReturn = 0;
fReturn = 0;
textBox1.Text = fd.SelectedPath;
Scanner scanner = new Scanner();
scanner.Show();
fscan(fd.SelectedPath);
dscan(fd.SelectedPath);
scanner.Close();
MessageBox.Show("File : " + fReturn + ", Folder : " + dReturn, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private int dscan(string path)
{
try
{
foreach (string d in Directory.GetDirectories(path))
{
dReturn = dReturn + 1;
dscan(d);
Application.DoEvents();
}
}
catch(Exception)
{
ListViewItem access = new ListViewItem(path);
listView1.Items.Add(access);
}
return dReturn;
}
I want know number of folders in selected path. So I made a recursive function as above. But The number of folders not the same as PC property view. Please Help me... Fine when the path is small, the problem arises when large.
Thanks for your comment. Sorry, It was Not enough description. I show you some image.
like this my program search more number of folder.