C#第十二天

1、Directory 操作文件夹

1)创建文件夹

1 Directory.CreateDirectory(@"C:\a");
2             Console.WriteLine("创建成功");
3             Console.ReadKey();
View Code

2)删除文件夹

1             Directory.Delete(@"C:\a", true);
2             Console.WriteLine("删除成功");
3             Console.ReadKey()
View Code

3)剪切文件夹

1             Directory.Move(@"c:\a", @"C:\Users\SpringRain\Desktop\new");
2             Console.WriteLine("剪切成功");
3             Console.ReadKey();
View Code

4)获得指定目录(文件夹)下所有文件(不包括文件夹)的全路径

1            string[] path = Directory.GetFiles(@"C:\Users\SpringRain\Desktop\Picture", "*.jpg");
2             for (int i = 0; i < path.Length; i++)
3             {
4                 Console.WriteLine(path[i]);
5             }
6             Console.ReadKey();
View Code

5)获得指定目录下所有文件夹的全路径

1             string[] path = Directory.GetDirectories(@"C:\Users\SpringRain\Desktop\new");
2             for (int i = 0; i < path.Length; i++)
3             {
4                 Console.WriteLine(path[i]);
5             }
6             Console.ReadKey();     
View Code

6)判断指定的文件夹是否存在

1             if (Directory.Exists(@"C:\a\b"))
2             {
3                 for (int i = 0; i < 100; i++)
4                 {
5                     Directory.CreateDirectory(@"C:\a\b\" + i);
6                 }
7             }
8             Console.WriteLine("OK");
9             Console.ReadKey();    
View Code

2、WebBrowser浏览器控件

1             private void button1_Click(object sender, EventArgs e)
2             {
3                 string text = textBox1.Text;
4                 Uri uri = new Uri("https://" + text);
5                 webBrowser1.Url = uri;
6             }            
View Code

 

posted @ 2015-11-09 09:33  菜鸟,你好  阅读(173)  评论(0)    收藏  举报