Using C++ Standard Library File I/O in Windows Store apps

By default, the following simple piece of standard C++ code will not work in Windows Store apps.

wofstream out(L"c:\\temp\\Data.txt");
out << L"Foo" << endl;

The reason is that Windows Store apps run with low privileges, meaning that there are restrictions on which files and folders you are allowed to access.
This is a problem for debugging, because often you want to quickly dump some data to a file and inspect the result.

Luckily, there is a way to make the above code work. The only thing you have to do is to grant “ALL APPLICATION PACKAGES” read/write access to the folder you want. 🙂

Share

Leave a Comment

Name: (Required)

E-mail: (Required)

Website:

Comment: