简体   繁体   English

CreateDirectory函数不起作用

[英]CreateDirectory function doesn't work

I am trying to create a directory using CreateDirectory function. 我正在尝试使用CreateDirectory函数创建目录。 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 . 还要确保以admin身份运行程序(.exe)。 You need to have admin privileges to create a folder in C:\\Users. 您需要具有管理员权限才能在C:\\ Users中创建一个文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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