jQuery and ASP.NET

February 25, 2010

Create Nested Directories in C# and VB.NET




A lot of developers do not know that Directory.CreateDirectory() can be used to create directories and subdirectories as specified by the path. Here’s an example

C#

static void Main(string[] args)
{
try
{
Directory.CreateDirectory(@"D:\ParentDir\ChildDir\SubChildDir\");
Console.WriteLine("Directories Created");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

VB.NET

Shared Sub Main(ByVal args() As String)
Try
Directory.CreateDirectory("D:\ParentDir\ChildDir\SubChildDir\")
Console.WriteLine("Directories Created")
Console.ReadLine()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub

OUTPUT

CreateNestedDirectories



'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

2 Responses to "Create Nested Directories in C# and VB.NET"
  1. john alphen said...
    March 12, 2010 7:54 PM

    The .NET framework comes bundled with a lot of advantages, which makes it widely used tool for .NET application development. In .NET ,
    I need some explanation regarding c# to vb conversion..
    Anykind of help would be greatly appreciated.

  2. ASP .NET Developers Blog said...
    January 31, 2012 4:07 AM

    Your article is very interesting. It is very useful and helpful for the Developers to develop the application. Thanks for share this valuable post.

 

Copyright © 2009-2011 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions