Click here to Skip to main content
15,443,631 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Trying to create write a file with vars. CArcive fails but the message box does not execute.

What I have tried:

               AfxMessageBox("Failed to save file!");
              CArchive ar(&f,CArchive::store);
              ar<<//Some vars.
Updated 26-Jun-21 5:31am

1 solution

Probably, it's a permissions problem: Win10 is much,. much stricter on what you can write where, so unless you plan your data directories carefully and ensure that the relevant user(s) have the correct permissions to read and write file in that folder, it will fail.

Some examples of places you can't write a file in Win10 include the application folder (because Program Files is write protected to all non-elevated users to prevent virus activity) and the root directory of the boot drive (for security reasons you don't want boot files changed either!)
There are other folders, but those are the most common mistakes.

Use the debugger and see exactly what is going on while your code runs.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900