title: UWP App Keeps Throwing Unauthorized Access Exception
body: <p>I am making an UWP App and I keep having a <code>System.UnauthorizedAccessException</code></p>
  
  <p>Here is the full Code of my main file</p>
  
  <pre><code>private void SaveButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
          {
              var user = new Configuration();
              string Email = txtEmail.Text.Trim();
  
                  user[Email]["Value"].StringValue = "test";
  
              string dest = Path.GetFullPath(@"C:\Users\IT\Desktop\AttendanceApp\AttendanceApp\bin\x86\Debug\AppX\Test\user.cfg");
              user.SaveToFile(dest);
          }
  </code></pre>
  
  <p>As I was reading the documentation for File Access Permission for UWP apps, it had suggested to add this line</p>
  
  <blockquote>
    <p>
    xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    IgnorableNamespaces="uap mp uap5 rescap"> ... 
         </p>
  </blockquote>
  
  <p>And this is my AppxManifest file</p>
  
  <pre><code>&lt;Package xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp uap5 rescap" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"  xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"&gt;
  ---
    &lt;Capabilities&gt;
      &lt;rescap:Capability Name="broadFileSystemAccess" /&gt;
    &lt;/Capabilities&gt;
  </code></pre>
  
  <p>So when I try to save a file. I still keep having this error.</p>
  
  <blockquote>
    <p>System.UnauthorizedAccessException   HResult=0x80070005<br>
    Message=Access to the path
    'C:\Users\IT\Desktop\AttendanceApp\AttendanceApp\bin\x86\Debug\AppX\Test\user.cfg'
    is denied.   Source=System.Private.CoreLib   StackTrace:    at
    System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)<br>
    at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare
    share, FileOptions options)    at System.IO.FileStream..ctor(String
    path, FileMode mode, FileAccess access, FileShare share, Int32
    bufferSize, FileOptions options)    at
    SharpConfig.Configuration.SaveToFile(String filename, Encoding
    encoding)    at SharpConfig.Configuration.SaveToFile(String filename) 
    at AttendanceApp.MainPage.SaveButton_Click(Object sender,
    RoutedEventArgs e) in
    C:\Users\IT\Desktop\AttendanceApp\AttendanceApp\MainPage.xaml.cs:line
    57</p>
  </blockquote>
  
  <p>By the way I am also using <code>SharpConfig</code> to edit my <code>.cfg</code> files</p>
  
  <p>Any ideas why this happens? Any help would be great</p>