zoukankan      html  css  js  c++  java
  • 删除无用网站无用的图片源码

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

    namespace DeleteFilesNoNeed
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                try
                {

             
                zj123.SQLDB.DbAccess dba = new zj123.SQLDB.DbAccess(this.textBox2.Text.Trim());
                //插入临时表数据--对应年月的
               // string tempInsertSql = "insert into tempDataFiles([FileName]) select [FileName] from datafiles where [filename] like '%"+this.textBox1.Text.Trim()+"%'";
               // string tempDeleteSql = "delete from tempDataFiles";
                //dba.GetState(tempDeleteSql + ";" + tempInsertSql + ";");
                //dba.GetState(tempDeleteSql);
                StringBuilder sbsql = new StringBuilder("delete from DriveFiles;");
                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(this.folderBrowserDialog1.SelectedPath);

                foreach (System.IO.FileInfo fi in dir.GetFiles())
                {
                    sbsql.AppendFormat("insert into DriveFiles([FileName],[FilePath]) values('{0}','{1}');",fi.Name,fi.FullName);

                }
                foreach(System.IO.DirectoryInfo di in dir.GetDirectories())
                {
                    foreach (System.IO.FileInfo fi in di.GetFiles())
                    {
                        sbsql.AppendFormat("insert into DriveFiles([FileName],[FilePath]) values('{0}','{1}');", fi.Name, fi.FullName);

                    }

                }
                dba.GetState(sbsql.ToString());
                string tempDeletSql = "select * from DriveFiles where ltrim(rtrim([FileName])) not in(select ltrim(rtrim([FileName])) from tempDataFiles)";
                DataTable dt = dba.GetTable(tempDeletSql);
                int i = 0;
                int a = dt.Rows.Count;
               // StringBuilder sb = new StringBuilder();
                foreach (DataRow dr in dt.Rows)
                {
                    System.IO.File.Delete(Convert.ToString(dr["FilePath"]).Trim());
                 //   sb.Append(Convert.ToString(dr["FilePath"]).Trim()).Append(System.Environment.NewLine);
                    i++;
                    this.label4.Text = "正在删除" + i.ToString()+"---共"+a.ToString().ToString();
                    Application.DoEvents();
                }
               // this.richTextBox1.Text = sb.ToString();

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }


            }

            private void button2_Click(object sender, EventArgs e)
            {
                this.folderBrowserDialog1.ShowDialog();
            }

            private void button3_Click(object sender, EventArgs e)
            {
                string filePath = this.folderBrowserDialog1.SelectedPath;

            }
        }
    }

  • 相关阅读:
    利用UltraScale和UltraScale+FPGA和MPSOC加速DSP设计生产力
    ARM系列处理器和架构
    Thumb扩展
    使用Redis分布式锁处理并发,解决超卖问题
    idea指定启动参数、环境变量
    Json返回结果为null属性不显示解决
    Spring Cloud Zuul 网关服务的fallback
    记录一次URL中有特殊字符怎么处理?
    logback的使用和logback.xml详解
    通过gitlab的webhook触发Jenkins自动构建设置
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835625.html
Copyright © 2011-2022 走看看