IO 创建目录,并常见文件
1.创建目录。
创建目录和文件
1 string path = @"c:\wtqCreate";
2 string pathTxt = path + @"\my.txt";
3 if (Directory.Exists(path))
4 {
5
6 Directory.Delete(path,true);
7 Directory.CreateDirectory(path);
8 using (StreamWriter sw = File.CreateText(pathTxt))
9 {
10 sw.WriteLine("my name is wtq");
11 sw.WriteLine("and what's your name");
12 sw.WriteLine("my name is wwttqq");
13 sw.WriteLine("I Can do everyThing");
14 }
15 }
2 string pathTxt = path + @"\my.txt";
3 if (Directory.Exists(path))
4 {
5
6 Directory.Delete(path,true);
7 Directory.CreateDirectory(path);
8 using (StreamWriter sw = File.CreateText(pathTxt))
9 {
10 sw.WriteLine("my name is wtq");
11 sw.WriteLine("and what's your name");
12 sw.WriteLine("my name is wwttqq");
13 sw.WriteLine("I Can do everyThing");
14 }
15 }