using System; using System.Windows.Forms; using System.IO; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (File.Exists("c:\\testFile.txt")) { //shows message if testFile exist MessageBox.Show ("File 'testFile' Exist "); } else { //create the file testFile.txt File.Create("c:\\testFile.txt"); MessageBox.Show("File 'testFile' created "); } } } }