Error in line: await instance.CreateFile(); The await operator can only be used within an async method. Consider marking this method with the async modifier and changing its return type to Task It's my understanding that the method is already asynchronous, I'm not sure what I am doing wrong. This is on a UWP app in VS 2015.
public sealed partial class MainPage : Page
{
private List<Customer> Customers;
public MainPage()
{
this.InitializeComponent();
CustomerDataAccessLayer instance = new CustomerDataAccessLayer();
await instance.CreateFile();
}
}
public class CustomerDataAccessLayer
{
public StorageFile mfile;
public async Task CreateFile()
{
mfile = await ApplicationData.Current.LocalFolder.GetFileAsync("Customers.xml");
if (mfile == null)
{
mfile = await ApplicationData.Current.LocalFolder.CreateFileAsync("Customers.xml", CreationCollisionOption.ReplaceExisting);
}
else
{
}
return;
}
}