using System;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string path = textBox1.Text + textBox2.Text + ".txt"; //测试文件存储路径
if (File.Exists(path))
{
MessageBox.Show("文件已经存在,请更换文件名!!!","文件存在提示",);
Environment.Exit(0);
}
else
{
StreamWriter sw = File.CreateText(path); // 创建文件
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}