private async Task<StorageFile> GetCsvFile()
{
var localFolder = KnownFolders.DocumentsLibrary;
var file = await localFolder.CreateFileAsync("NRBcatalogue.csv", Windows.Storage.CreationCollisionOption.ReplaceExisting);
String rk = "";
for (int i = 0; i < k1.Count; i++)
{
rk += k1[i] + "\n";
}
await Windows.Storage.FileIO.WriteTextAsync(file, rk);
return file;
}
private async void AppBarButton_Click_1(object sender, RoutedEventArgs e)
{
EmailMessage email = new EmailMessage();
email.To.Add(new EmailRecipient("[email protected]"));
email.Subject = "NRB Catalogue";
var file = await GetCsvFile(); //Error occured here
email.Attachments.Add(new EmailAttachment(file.Name, file));
await EmailManager.ShowComposeNewEmailAsync(email);
}
The Error Details are: A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.ni.dll. An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.ni.dll but was not handled in user code. Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))