开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜