So I have had an error "Object reference not set to an instance of an object".
Here is the area where the error is occurring from:
private async void Savebutton_click(object sender, RoutedEventArgs e)
{
string recipename = recipenametextbox.Text.ToString();
string recipemethod = methodtextbox.Text.ToString();
string recipeingredients = ingredientstextbox.Text.ToString();
//File names.
string recipenamefilename = recipename + "title.txt";
string recipemethodfilename = recipename + "method.txt";
string recipeingredientsfilename = recipename + "ingredients.txt";
await currentrecipe.folder.CreateFolderAsync(recipename);
await currentrecipe.folder.CreateFileAsync(recipenamefilename);
File.WriteAllText(recipenamefilename, recipename);
await currentrecipe.folder.CreateFileAsync(recipemethodfilename);
File.WriteAllText(recipemethodfilename, recipemethod);
await currentrecipe.folder.CreateFileAsync(recipeingredientsfilename);
File.WriteAllText(recipeingredientsfilename, recipeingredients);
//Clear currentrecipe ready for next recipe.
currentrecipe.folder = null;
currentrecipe.Picturefile = null;
currentrecipe.recipebackgroundcolourenabled = false;
}
I am presuming that it is something to do with initialising the currentrecipe variable's StorageFolder member (currentrecipe is a recipie varible). Also I don't think it is a duplicate of the NullReferanceException question, simply due to the fact that I know what the NullReferanceException is, and I know how to fix it in a way, but I do not know how to fix it for this particular NullReferanceException - for Storage Folders. Also the error happens at await currentrecipe.folder.CreateFolderAsync(recipename).
Here is my recipie class:
public sealed class recipie
{
public StorageFile Picturefile;
public StorageFolder folder;
public bool recipebackgroundcolourenabled;
}