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 Ex06_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show(this, "文件路径及名称不能为空！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (File.Exists(textBox1.Text))
            {
                MessageBox.Show(this, "该文件已存在！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                FileStream fs = File.Create(textBox1.Text);
                fs.Close();
                MessageBox.Show(this, "成功创建文件！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show(this, "文件路径及名称不能为空！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (!File.Exists(textBox1.Text))
            {
                MessageBox.Show(this, "要删除的文件不存在！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                File.Delete(textBox1.Text);
                MessageBox.Show(this, "成功删除了文件！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
