My form does not show when I click a button but the program continues as I can see from the debug in C#(WindowsFormApp).
The button's code is:
private void button1_Click(object sender, EventArgs e)
{
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string files = string.Join(",", Directory.GetFiles(desktop, "*", SearchOption.AllDirectories).ToList().ToArray());
textBox1.Text = files;
string dir = string.Join(",", Directory.GetDirectories(desktop, "*", SearchOption.AllDirectories).ToList().ToArray());
textBox2.Text = dir;
int count;
for (count = 0; count <= dir.Split(',').Length - 1; count++)
{
Console.WriteLine(dir.Split(',')[count].Replace(desktop, "").Replace('\\', '/'));
mkdir(dir.Split(',')[count].Replace(desktop, "").Replace('\\', '/'));
}
for (count = 0; count <= files.Split(',').Length - 1; count++)
{
Console.WriteLine(files.Split(',')[count].Replace(desktop, "").Replace('\\', '/'));
upload(files.Split(',')[count], files.Split(',')[count].Replace(desktop, "").Replace('\\', '/'));
}
}
where mkdir and upload is defined to create and upload files using ftp. Is there a way I can still see the form while the loops are running.
Note: I can view the form again when the loops finish.
Edit: Many of the answers included were about multithreading and async usage. Can you please help how exactly I can implement that.