1、Directory 操作文件夹
1)创建文件夹
1 Directory.CreateDirectory(@"C:a"); 2 Console.WriteLine("创建成功"); 3 Console.ReadKey();
2)删除文件夹
1 Directory.Delete(@"C:a", true); 2 Console.WriteLine("删除成功"); 3 Console.ReadKey()
3)剪切文件夹
1 Directory.Move(@"c:a", @"C:UsersSpringRainDesktop ew"); 2 Console.WriteLine("剪切成功"); 3 Console.ReadKey();
4)获得指定目录(文件夹)下所有文件(不包括文件夹)的全路径
1 string[] path = Directory.GetFiles(@"C:UsersSpringRainDesktopPicture", "*.jpg"); 2 for (int i = 0; i < path.Length; i++) 3 { 4 Console.WriteLine(path[i]); 5 } 6 Console.ReadKey();
5)获得指定目录下所有文件夹的全路径
1 string[] path = Directory.GetDirectories(@"C:UsersSpringRainDesktop ew"); 2 for (int i = 0; i < path.Length; i++) 3 { 4 Console.WriteLine(path[i]); 5 } 6 Console.ReadKey();
6)判断指定的文件夹是否存在
1 if (Directory.Exists(@"C:a")) 2 { 3 for (int i = 0; i < 100; i++) 4 { 5 Directory.CreateDirectory(@"C:a" + i); 6 } 7 } 8 Console.WriteLine("OK"); 9 Console.ReadKey();
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 }