Using this code:
private async void writeToStorage(string contents)
{
var roamingFolder = Windows.Storage.ApplicationData.Current.RoamingFolder;
var storFile = await roamingFolder.CreateFileAsync("test", CreationCollisionOption.ReplaceExisting);
await Windows.Storage.FileIO.WriteTextAsync(storFile, contents);
}
Do I need to close the file? And if so.. how do I do that? There is no Close on the storFile.
No you do not need to close this file.
StorageFolderandStorageFileinstances are just a pointers to a folder and a file.Using the
WriteTextAsyncmethod will open/write and close automatically the stream.