title: Xamarin Forms - File System
body: <p>I'm developing a cross-platform application (UWP - Target version 16299, Android Target Version Pie and iOS; Visual Studio 2019 - Xamarin.Forms 4.1.0) which needs to communicate with a local DB file created inside AppData. All nice and fun until I try to export the information to another file, outside the AppData.
  I've tried a bunch of things with no success and I'm curious why it works for you and not for me.</p>
  
  <p>This is the latest code I've tested, similar to the others and with the same result:<br>
  Exception thrown: '<code>System.UnauthorizedAccessException</code>' in <code>System.Private.CoreLib.dll</code></p>
  
  <pre class="lang-cs prettyprint-override"><code>using Plugin.FilePicker;
  using Plugin.FilePicker.Abstractions;
  using Plugin.Permissions;
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Diagnostics;
  using System.IO;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Xamarin.Forms;
  using Xamarin.Forms.PlatformConfiguration;
  
  namespace Testing
  {
  
      [DesignTimeVisible(false)]
      public partial class MainPage : ContentPage
      {
          public MainPage()
          {
              InitializeComponent();
          }
          private Plugin.FilePicker
              .Abstractions.FileData file;
  
  
          private async void ImportBtn_Clicked(object sender, EventArgs e)
          {
              try
              {
                  file = await CrossFilePicker.Current.PickFile();
  
  
              }
              catch (Exception ex)
              {
  
              }
  
              file.FileName = "rooms.jpg";
              file.FilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
              await CrossFilePicker.Current.SaveFile(file);
          }
  
          private void ExportBtn_Clicked(object sender, EventArgs e)
          {
  
              {
                  string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                  string localFilename = "download.txt";
                  string localPath = Path.Combine(documentsPath, localFilename);
  
                  try 
                  {  
                     File.Create(localPath); 
                  }
                  catch(Exception ex) 
                  { Debug.WriteLine(ex); }
                  Debug.WriteLine(localPath);
  
              }
  
          }
      }
  }
  </code></pre>
  
  <p>I want to mention that all capabilities have been ticked, in a desperate attempt to get something to work, the import_clicked works as intended and the folders tried (Personal, Music, Pictures, Commons) are empty.</p>