How to gain access to KnownFolders.DocumentsLibrary
c#, windows-8, windows-runtime, windows-store-apps
Solution
"Documents library" capability in Visual Studio 2013 has been removed since it is only available for Windows Store Company accounts. Without this capability you will get "Access is denied".
For more information, read here: http://lunarfrog.com/blog/2013/07/05/documents-library-capability-winrt/
Problem
I'm trying to save a string of user inputs to a file in a windows runtime app. However I'm getting the error `System.UnauthorizedAccessException`. How do I gain access to this Library? ``` static private async Task WriteDataToFileAsync(string fileName, string content) { byte[] data = Encoding.Unicode.GetBytes(content); var folder = KnownFolders.DocumentsLibrary; var file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); using (var s = await file.OpenStreamForWriteAsync()) { await s.WriteAsync(data, 0, data.Length); } } ```