如何批量删除文件后辍名为.TZ的文件

解决方案 »

  1.   

         string[] strFiles = System.IO.Directory.GetFiles("c:\\","*.tz");
                foreach(string file in strFiles)
                {
                    System.IO.File.Delete(file);
                }
      

  2.   

    /***
    * 根据查找指定路径下的所有.TZ结尾的文件后删除
    * ***/
    DirectoryInfo dir = new DirectoryInfo("Path");//Path :要查找文件的路径
    FileInfo[] e = dir.GetFiles("*.TZ");
    foreach (FileInfo file in e)
    {
        file.Delete();
    }     我只知道这个方法了~不知道对你有没有帮助~
      

  3.   

    批量,注意是运行时的路径,或者使用绝对路径,调试时候路径和真正执行时的路径不一样。
    Process p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;            p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;            p.Start();
                p.StandardInput.WriteLine("del *.tz");