I have that method that counts files in a certain folder:
private void countfiles(string path)
{
if (path != "")
{
DirectoryInfo dir = new DirectoryInfo(path);
foreach (FileInfo filesindires in dir.GetFiles())
{
if (filesindires.FullName != Application.ExecutablePath)
{
num_files++;
Thread.Sleep(1);
}
}
foreach (DirectoryInfo dirsinfolder in dir.GetDirectories())
{
countfiles(dirsinfolder.FullName);
}
}
}
and when the user clicks on the count button I wanted to make a thread, so the program doesn’t hang.
Thread count = new Thread(new ThreadStart(countfiles(@"E:/test")));
But I get this error even before debugging:
Method Name Expected
I dont understand; what does that error need from me?
Finally thanks a lot for your help in advance.
It’s
You don’t have to pass the parameters, just the method name.
Also you will need to change the type of the parameter to
object, notstring. Alternatively, if you want to keep thestringparameter, you can use: