First, assuming Form1 is the main form, and you hide it, how will you show it again unless Form2 has a reference to it ? Do you really need to show a second Form ?
private void richTextBox1_Load(object sender, EventArgs e)
{
richTextBox1.Text = "Directories:" + GetDirectoryCount() + Environment.NewLine + "Files:" + GetFileCount();
}
A RichTextBox has no 'Load Event: this should be the Form2 'Load Event.
Why let the user show Form2 without making sure you have a valid Path:
public void button1_Click(object sender, EventArgs e)
{
button2.Enabled = false;
FolderBrowserDialog folder = new FolderBrowserDialog();
if (folder.ShowDialog() == DialogResult.OK)
{
folderPath = Path.GetDirectoryName(folder.SelectedPath);
textBox1.Text = folderPath;
button2.Enabled = true;
}
else
{
}
}
You can use these forms to simplify your Form2 methods:
return Directory.GetFiles(folderPath).Length;
return Directory.GetDirectories(folderPath).Length;