I have to make a backup of a database through this code which must have access to the File System.
I added the references to the Package.appxmanifest as from this link and I also activated the app permission in the settings.
Settings -> Privacy -> File System and I have activated the app permission. This way you should have access to the files through the paths but it still crashes.
MainPage.xaml.cs:
string constring = "server=localhost;user=user;pwd=password;database=dbtest;";
string file = "C:\\backup.sql";
using (MySqlConnection conn = new MySqlConnection(constring))
{
using (MySqlCommand cmd = new MySqlCommand())
{
using (MySqlBackup mb = new MySqlBackup(cmd))
{
cmd.Connection = conn;
conn.Open();
mb.ImportFromFile(file);
conn.Close();
}
}
}
Package.appxmanifest:
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="broadFileSystemAccess" />
</Capabilities>
The error is:
Access to the path C:\backup.sql' is denied.
Is there anything I overlook?
Thanks in advance.