DirectoryInfo di = new DirectoryInfo(@"C:\abc");
int n = 10;
private void button1_Click_1(object sender, EventArgs e)
{
if (!di.Exists) di.Create();
for(int idx = 1; idx<=n; idx++)
{
FileInfo fi = new FileInfo(String.Format(@"C:\abc\file{0:d}.txt", idx));
if (!fi.Exists) fi.Create().Dispose();
}
}
private void button2_Click(object sender, EventArgs e)
{
if (!di.Exists) di.Create();
foreach(FileInfo fi in di.GetFiles()) fi.Delete();
}
That should do it!
Cheers!
—MRB