一个winform转换成控制台的问题 ?

帮忙把一下代码改成控制台咯,多谢了 。。。

我一窍不通 、

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Data.SqlClient;
using System.IO;
using System.Windows.Forms;
using System.Net;
using System.Collections;

namespace WindowsGetTree
{
  
    public partial class Form3 : Form
    {
        List<FileInfoEx> list = new List<FileInfoEx>();
       
        public Form3()
        {
            InitializeComponent();
            LoadFileList(@"D:\Demo\backupdir");
        
            for (int i = 0; i < list.Count; i++)
            {
                this.richTextBox1.Text += list[i].ToString() + "\r\n";
            }

            DateTime maxdate = DateTime.Now.AddYears(-20);

            for (int i = 0; i < list.Count; i++)
            {
                if (maxdate < list[i].date)
                    maxdate = list[i].date;
            }

            DateTime PaTime = maxdate.AddDays(-20);
            long sum = 0;
            for (int i = 0; i < list.Count; i++)
            {
                if (PaTime < list[i].date)
                {
                    sum += list[i].size;
                }              
            }
            this.textBox1.Text = sum.ToString()+"KB";
        }
        private void Form3_Load(object sender, EventArgs e)
        {
         
        }
        public void LoadFileList(string dir)
        {
            foreach (String directoryPath in Directory.GetDirectories(dir))
            {
                LoadFileList(directoryPath);
            }

            foreach (String filename in Directory.GetFiles(dir))
            {
                FileInfo fi = new FileInfo(filename);
                FileInfoEx fiex = new FileInfoEx();
                fiex.filename = filename;
                fiex.date = fi.LastWriteTime;
                fiex.size = fi.Length;
                list.Add(fiex);
            }
        }

    }

    public class FileInfoEx
    {
        public string filename;
        public DateTime date;
        public long size;

        public override string ToString()
        {
            return filename + " - " + date + " - " + size;
        }
    }

}

慕哥6287543
浏览 445回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP