- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace CreateDirectoryTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- string path = @"C:\Users\pengshiyu\Desktop\test";
- if (Directory.Exists(path))
- {
- Console.WriteLine("文件夹存在,无需创建! " + path);
- }
- else
- {
- //使用try...catch语句避免出现异常
- try
- {
- Directory.CreateDirectory(path);
- Console.WriteLine("文件夹创建成功:" + path);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
- Console.ReadKey();
- }
- }
- }
C#编程-113:文件夹操作之创建_彭世瑜_新浪博客
原创
©著作权归作者所有:来自51CTO博客作者彭世瑜的原创作品,请联系作者获取转载授权,否则将追究法律责任
VS快速整理层级关系:Ctrl+K+D
使用try...catch语句块避免文件夹访问被拒绝异常

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
c#文件生成Dll文件_彭世瑜_新浪博客
在vs中设置输出类型即可
python java linux c++