Jimmy
Jimmy

Reputation: 21

CreateDirectory function doesn't work

I am trying to create a directory using CreateDirectory function. But it doesn't seem to work as i expect. What's wrong with my function?

#include "stdafx.h"
#include<windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
    wchar_t *path = L"C:\\Users\TempFolder";
    CreateDirectory ( path , NULL);
    return 0;
}

Upvotes: 1

Views: 1991

Answers (1)

Deadlock
Deadlock

Reputation: 4519

You need to have a another backslash in there:

L"C:\\Users\\TempFolder"

And also make sure to run your program (.exe) as admin. You need to have admin privileges to create a folder in C:\Users.

Upvotes: 3

Related Questions