Folder Creation In Windows C#
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!");
精彩评论