public void delFIlesandDir(string path,string dirname)
{
DirectoryInfo dinfo = new DirectoryInfo(path);
try
{
foreach (DirectoryInfo d in dinfo.GetDirectories())
{
if (d.Name == dirname)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("attrib *.* -r -h -a -s /S /D");
p.StandardInput.WriteLine(@"rd "+@d.FullName+" /s /q");
// p.WaitForExit(3000);
p.StandardInput.WriteLine("exit");
p.Close();
}else if (d.GetDirectories().Length > 0)
{
delFIlesandDir(d.FullName,dirname);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}