//创建文件夹 Directory.CreateDirectory(@"C:a"); Console.WriteLine("创建成功"); Console.ReadKey(); //删除文件夹 Directory.Delete(@"C:a",true); Console.WriteLine("删除成功"); Console.ReadKey(); //剪切文件夹 Directory.Move(@"c:a", @"C:UsersSpringRainDesktop ew"); Console.WriteLine("剪切成功"); Console.ReadKey(); //获得指定文件夹下所有文件的全路径 string[] path = Directory.GetFiles(@"C:UsersSpringRainDesktopPicture","*.jpg"); for (int i = 0; i < path.Length; i++) { Console.WriteLine(path[i]); } Console.ReadKey(); //获得指定目录下所有文件夹的全路径 string[] path = Directory.GetDirectories(@"C:UsersSpringRainDesktop ew"); for (int i = 0; i < path.Length; i++) { Console.WriteLine(path[i]); } Console.ReadKey(); //判断指定的文件夹是否存在 if (Directory.Exists(@"C:a")) { for (int i = 0; i < 100; i++) { Directory.CreateDirectory(@"C:a" + i); } } Console.WriteLine("OK"); Console.ReadKey(); //目录属性设置方法:DirectoryInfo.Atttributes //下面的代码设置c: empuploadsNewDirectory目录为只读、隐藏。与文件属性相同,目录属性也是使用FileAttributes来进行设置的。 DirectoryInfo NewDirInfo = new DirectoryInfo(@"c: empuploadsNewDirectoty"); NewDirInfo.Atttributes = FileAttributes.ReadOnly|FileAttributes.Hidden;