How to create file in Visual c++
I try create file in visual studio c++.
But it now work, what is wrong?
CreateFile("1",
GENERIC_READ | GENE开发者_如何学JAVARIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
If you try to create a file (not open it), you should not specify the OPEN_EXISTING flag. Instead, pass the CREATE_NEW constant:
CreateFile("1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_NEW,
FILE_FLAG_OVERLAPPED,
NULL);
This code tries to open existing file: OPEN_EXISTING. Replace it with CREATE_NEW to create new file.
精彩评论