- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a Directory using C#?
To create, move and delete directories in C#, the System.IO.Directory class has methods.
Firstly, import the System.IO namespace.
Now, use the Director.CreateDirectory() method to create a directory in the specified path −
string myDir = @"D:\NEW"; if (!Directory.Exists(myDir)) { Directory.CreateDirectory(myDir); }
In the same way, you can create a sub-directory −
string mysubdir = @"C:\NEW\my\"; Directory.CreateDirectory(mysubdir);
Advertisements