Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

CreateDirectory (kernel32)
 
.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern bool CreateDirectory(string lpPathName,
   IntPtr lpSecurityAttributes);

User-Defined Types:

None.

Notes:

This is a alternitive to the Directory.CreateDirectory() method provided by the .NET Framework. The advantage of using the DllImport is that the running assembly does not require access to the root directory structure. The disadvantage is that it will only create the end most directory where as the method provided by .NET will create the entire folder structure. However you 'could' create a recursive function to do this...

Tips & Tricks:

Please add some!

Sample Code:

string path = "c:\\test\\mydir";
CreateDirectory(path, IntPtr.Zero);

Alternative Managed API:

[DllImport("msvcrt.dll", SetLastError=true)]
static extern int _mkdir(string path);

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions