// constructor public MainViewModel() { RandomFile randomFile = new RandomFile(); ReadContentsCommand = new Command(async() => { // check to see if the file exists var exists = await randomFile.TestRandomFile(); if (!exists) { // create the file if it does not exist await randomFile.CreateRandomFile(); } // read the contents out of the file var value = await randomFile.LoadRandomFile(); // update the UI if (!exists) { FileContents = "Created random file: " + value; } else { FileContents = "Existing random file: " + value; } }); DeleteFileCommand = new Command(async() => { // check to see if the file exists var exists = await randomFile.TestRandomFile(); if (exists) { // delete the file if it exists await randomFile.DeleteRandomFile(); } // update the UI if (!exists) { FileContents = "No random file to delete."; } else { FileContents = "Deleted random file."; } }); }