CreateDirectory (kernel32)
Last changed: WithLithum-112.101.111.191

.
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