So I'm trying to output some data to a csv
file. I've got no issues with the code the first time it runs but it breaks if I don't close and reopen the program (because the file is still in use.) I'm creating it with the following code.
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(Path.GetDirectoryName(folderPath));
StorageFile file = await folder.CreateFileAsync(outputFile, CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(file , content);
It was suggested I should be using the using
construct but when I try it I get this error.
CS1674 'StorageFile': type used in a using statement must be implicitly convertible to 'System.IDisposable'.
There's obviously something I'm ignorant of but I don't know what.
Any help would be much appreciated.
Your class must implement IDisposable Interface
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.