using System;
          using System.Collections.Generic;
          using System.ComponentModel;
          using System.Data;
          using System.Drawing;
          using System.Linq;
          using System.Text;
          using System.Windows.Forms;
          using System.IO;

          namespace TemplateFileDelete
          {
              public partial class DeleteFiles : Form
              {
                  int i = 0;
                  public DeleteFiles()
                  {
                      InitializeComponent();
                  }

                  private void BtOpen_Click(object sender, EventArgs e)
                  {
                      DealAction(sender, e);
                  }

                  private void BtOpen2_Click(object sender, EventArgs e)
                  {
                      DealAction(sender, e);
                  }
                  public void DealAction(object sender, EventArgs e)
                  {
                      fbdShow.ShowDialog();
                      Button bt = (Button)(sender);
                      if (bt.Name == "BtOpen")
                      {
                          this.TbPath1.Text = fbdShow.SelectedPath;
                      }
                      else if (bt.Name == "BtOpen2")
                      {
                          this.TbPath2.Text = fbdShow.SelectedPath;
                      }

                  }
                  public void Dirs(string path)
                  {
                      DirectoryInfo dis = new DirectoryInfo(path);
                      FileInfo[] files = dis.GetFiles();
                      foreach (FileInfo fi in files)
                      {
                          i++;
                          Application.DoEvents();
                          this.label1.Text = i.ToString();
                          try
                          {
                              File.Delete(fi.FullName);
                          }
                          catch (Exception ex)
                          {
                              this.richTextBox1.Text += ex.Message;
                       
                          }
                    
                        //  GetSqlFile(fi.FullName, this.textBox1.Text + fi.DirectoryName.Substring(2), fi.FullName.Substring(fi.FullName.LastIndexOf("\\") + 1), 1024, 768);
                      }
                      if (dis.GetDirectories().Length > 0)
                      {
                          for (int i = 0; i < dis.GetDirectories().Length; i++)
                          {
                              Dirs(dis.GetDirectories()[i].FullName);
                          }
                      }


                  }

                  private void BtDelete_Click(object sender, EventArgs e)
                  {
                      Dirs(this.TbPath1.Text.Trim());
                      Dirs(this.TbPath2.Text.Trim());
                  }

              }
          }


          文章來源:http://www.cnblogs.com/wangdetian168/archive/2008/12/21/1359315.html
          posted on 2010-09-28 10:54 sanmao 閱讀(92) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 开原市| 宁蒗| 微博| 富顺县| 谢通门县| 原阳县| 资中县| 永康市| 祁门县| 介休市| 大姚县| 健康| 宝坻区| 潍坊市| 达孜县| 昌图县| 绥芬河市| 即墨市| 通许县| 宁波市| 苏尼特左旗| 昌图县| 赞皇县| 蓝田县| 金堂县| 宁化县| 曲麻莱县| 璧山县| 瑞安市| 沧州市| 西贡区| 泸溪县| 五原县| 苍梧县| 昌黎县| 新沂市| 武山县| 平度市| 丹寨县| 富平县| 梁山县|