感觉和JAVA的也差不多。。。
只是在VS2012的IDE环境下,开发效率要高一些。可能开发效率就是微软的特色吧。。。
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 using System.IO; 11 12 namespace FD 13 { 14 public partial class Form1 : Form 15 { 16 public Form1() 17 { 18 InitializeComponent(); 19 } 20 21 private void button1_Click(object sender, EventArgs e) 22 { 23 if (textBox1.Text == string.Empty) 24 { 25 MessageBox.Show("file name can't be empty!"); 26 } 27 else 28 { 29 if (File.Exists(textBox1.Text)) 30 { 31 MessageBox.Show("This file have existed."); 32 } 33 else 34 { 35 File.Create(textBox1.Text); 36 } 37 } 38 } 39 40 private void button2_Click(object sender, EventArgs e) 41 { 42 if (textBox2.Text == string.Empty) 43 { 44 MessageBox.Show("folder name can't be empty."); 45 } 46 else 47 { 48 if (Directory.Exists(textBox2.Text)) 49 { 50 MessageBox.Show("this folder name have exiestd."); 51 } 52 else 53 { 54 Directory.CreateDirectory(textBox2.Text); 55 } 56 } 57 } 58 59 private void button3_Click(object sender, EventArgs e) 60 { 61 if (textBox3.Text == string.Empty) 62 { 63 MessageBox.Show("empty"); 64 } 65 else 66 { 67 FileInfo finfo = new FileInfo(textBox3.Text); 68 if (finfo.Exists) 69 { 70 MessageBox.Show("exist"); 71 } 72 else 73 { 74 finfo.Create(); 75 } 76 } 77 } 78 79 private void button4_Click(object sender, EventArgs e) 80 { 81 if (textBox4.Text == string.Empty) 82 { 83 MessageBox.Show("empty"); 84 } 85 else 86 { 87 DirectoryInfo dinfo = new DirectoryInfo(textBox4.Text); 88 if (dinfo.Exists) 89 { 90 MessageBox.Show("exist"); 91 } 92 else 93 { 94 dinfo.Create(); 95 } 96 } 97 } 98 } 99 }