简体   繁体   中英

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;
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM