file writing not working after call to open file dialog

后端 未结 2 691
北恋
北恋 2020-12-12 04:56

after call to following function i cant write to any files i tried c++ fstream and c\'s fopen what\'s wrong please help thanks in advance i am using codeblocks mingw windows

2条回答
  •  借酒劲吻你
    2020-12-12 05:56

    Try CreateFile and WriteFile.

    string s = "file.dat";
    
    HANDLE hFile = CreateFile(s.c_str(),       // name of the write
                       GENERIC_WRITE,          // open for writing
                       0,                      // do not share
                       NULL,                   // default security
                       CREATE_ALWAYS,          // Creates a new file, always
                       FILE_ATTRIBUTE_NORMAL,  // normal file
                       NULL);                  // no attr. template
    DWORD writesBytes;
    bool writeok = WriteFile(hFile, &Current_Doc, sizeof(Current_Doc), &writesBytes, NULL);
    
    CloseHandle(hFile);
    

    Similar problem, and my answer is here:

    OPENFILENAME open dialog

提交回复
热议问题