i'll just like create a new file on my C disk (and later on my network).
i would like pick a file on a folder with an openFilePicker (that's works) and next with a button copy this file on my desktop for example.
File property :
public StorageFile File { get; set; }
the openFilePicker code :
public async Task GetFileAsync()
{
var picker = new FileOpenPicker();
picker.ViewMode = PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add("*");
File = await picker.PickSingleFileAsync();
}
The code to save :
public async Task SaveFileAsync()
{
try
{
StorageFolder test2 = await StorageFolder.GetFolderFromPathAsync(@"C:\Users\bvens\Desktop");
await File.CopyAsync(test2, File.Name, NameCollisionOption.ReplaceExisting);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
But i have an UnauthorizedAccessException when a try to write in "saveFileAsync" =>
System.UnauthorizedAccessException: Accès refusé. (Exception from HRESULT:0x80070005 (E_ACCESSDENIED))
thanks
Edit the problem it's that in UWP the app is in a other thread and so don't have right to write. You need ton ask to your user that your app can go to the target file (like in android)
(We can close this issues)
When StorageFile.CopyAsync is used to copy a file that is encrypted to a destination that is not encrypted, the call will fail with the following exception: System.UnauthorizedAccessException: Access is denied. (Excep_FromHResult 0x80070005)
I think this is a problem
User contributions licensed under CC BY-SA 3.0