开发者

Folder Creation In Windows C#

开发者 https://www.devze.com 2023-02-15 05:49 出处:网络
I want to create dynamic folder by code in Windows C#.Suppose开发者_如何学C for each account holder in bank, I have to generate a folder.very simeple

I want to create dynamic folder by code in Windows C#.Suppose开发者_如何学C for each account holder in bank, I have to generate a folder.


very simeple

 if(!System.IO.Directory.Exists("Path"))
    {
        System.IO.Directory.CreateDirectory("Path");
    }


System.IO.Directory.CreateDirectory(string)

(Assuming it's not in a location that's protected, i.e. needs admin rights (such as Windows Vista/7 restrictions), and your application isn't requiring admin level)

You can also extend the DirectoryInfo class to accept a full path and recursively create it


You can use the Directory.CreateDirectory method:

DirectoryInfo di = Directory.CreateDirectory(@"C:\path\to\dir");
if(di.Exists)
   Console.WriteLine("Success!");
0

精彩评论

暂无评论...
验证码 换一张
取 消