txt随机生成器,用于随机生成多个txt文本文件的小程序,可以自定义生成数量。

该软件是用C#编写的,以下是程序源码:

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

namespace 随机生成txt
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        int Num = 0;
        private void Form1_Load(object sender, EventArgs e)
        {

        }

        void CreateTxt()
        {
            for (int i = 0; i < Num; i++)
            {
                StreamWriter sw = new StreamWriter(i.ToString() + ".txt");
                sw.WriteLine(i.ToString() + " " + DateTime.Now.ToString());
                sw.Close();
            }
            MessageBox.Show("生成完毕!");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Num = Convert.ToInt32(numUd.Value);
            Thread t = new Thread(CreateTxt);
            t.Start();
        }
    }
}