I am trying to integrate the Onedrive SDK to the UWP Portion of my Xamarin App, However in the Upload and Download code, I get the following exception when ever the following lines are reached:
using (var stream = await sqliteStorageFileFile.OpenStreamForReadAsync())
using (IRandomAccessStream appFileStream = await appFile.OpenAsync(FileAccessMode.ReadWrite))
Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.ni.dll An Exception: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) mscorlib
Here is the relevant code snippnets: UPLOAD:
I am trying to integrate the Onedrive SDK to the UWP Portion of my Xamarin App, However in the Upload and Download code, I get the following exception when ever the following lines are reached:
using (var stream = await sqliteStorageFileFile.OpenStreamForReadAsync()) using (IRandomAccessStream appFileStream = await appFile.OpenAsync(FileAccessMode.ReadWrite)) Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.ni.dll An Exception: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) mscorlib Here is the relevant code snippnets: UPLOAD:
DOWNLOAD:
public async Task Download(string filename) { await InitializeClient(); try { var filebuilder = OneDriveClient.Drive.Special.AppRoot.ItemWithPath(filename); var backedUpFile = await filebuilder.Request().GetAsync(); var fileStream = await filebuilder.Content.Request().GetAsync(); //Byte Creation for fileStream byte[] fileBytes; IRandomAccessStream stream = fileStream.AsRandomAccessStream(); using (DataReader reader = new DataReader(stream)) { fileBytes = new byte[stream.Size]; await reader.LoadAsync((uint)stream.Size); reader.ReadBytes(fileBytes); }
Please note the type of file I am trying to upload is a .db3 file (SQLite)