运行结果.PNG
代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApp6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
MessageBox.Show("请输入文件夹名称!");
}
else
{
DirectoryInfo d = new DirectoryInfo(textBox1.Text);
//实例化一个输入内容的目录
if(d.Exists)
{
MessageBox.Show("目录已存在,请重新输入");
}
else
{
d.Create();
}
}
}
}
}