tags:

views:

38

answers:

2

Using Visual Studio 2008 C++, how can I create a folder using code. For some reason, a simple CreateDirectory isn't working.

A: 

Are you by any chance trying to create a folder in your Visual Studio solution? If so, you could use code to do that, but you still have to right click the solution and add existing items.

Gabriel
Hmm, it's a Win32 Console Application (Empty Project---no precompiled header). I add a .cpp file, and write the code there. What include files should I use?
bob packer
You need to `#include <Windows.h>`
DeadMG
A: 

All I'm trying to do is create a folder. Nothing special. This code won't work.

#include <Windows.h>
#include <stdio.h>
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
CreateDirectory("c:\\dirn.txt");
}

It gives this error:

error C2660: 'CreateDirectoryW' : function does not take 1 arguments

bob packer
place the cursor on 'CreateDirectory' and press F1
Gabriel