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-10-11 09:28 sanmao 閱讀(200) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 通城县| 香格里拉县| 九台市| 林甸县| 田林县| 彭水| 右玉县| 西乌珠穆沁旗| 惠东县| 石家庄市| 遂宁市| 建德市| 武定县| 南开区| 云霄县| 葫芦岛市| 中江县| 东丰县| 吉安县| 武汉市| 台山市| 平顶山市| 苗栗市| 桐乡市| 海宁市| 奉化市| 新河县| 大城县| 临夏县| 自治县| 边坝县| 宁远县| 满洲里市| 民乐县| 洪雅县| 芦山县| 翁牛特旗| 濮阳县| 长春市| 北碚区| 曲麻莱县|