user3587624
user3587624

Reputation: 1471

UWP - Is there a folder within the package that I can get access to for creating files?

Since UWP are very restrictive in terms of read/write on files that are out of the package, I was wondering whether there is a good place where I can create a folder structure and then create some text files in it...

I was thinking on using %localappdata% but I get access denied.

I know we have available the Videos, Music, etc. folders but these don't make sense to my logic. (e.g.: doesn't make sense to store a txt file in the Music folder)

Can someone point me to where to store extra files?

Upvotes: 0

Views: 300

Answers (1)

mm8
mm8

Reputation: 169420

There is a a Local folder, a Roaming folder and a Temp folder in each app to which you can write folders and files.

// Create sample file; replace if exists.
Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync("sample.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);

Please refer to Jerry Nixon's blog post for more information: http://blog.jerrynixon.com/2012/06/windows-8-how-to-read-files-in-winrt.html

Upvotes: 3

Related Questions