【发布时间】:2023-03-06 17:49:01
【问题描述】:
我将网络中的数据序列化为 Json,我想将其保存到应用程序文件夹“Assets”中的路径中,如何使用本地存储?还是IsolatedStorage 是正确的选择?
string js = JsonConvert.SerializeObject(up, Formatting.Indented);
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile textFile = await localFolder.CreateFileAsync("upcoming.Json", CreationCollisionOption.ReplaceExisting);
using (IRandomAccessStream textStream = await textFile.OpenAsync(FileAccessMode.ReadWrite))
{
using (DataWriter textWriter = new DataWriter(textStream))
{
textWriter.WriteString(js);
await textWriter.StoreAsync();
}
}
【问题讨论】:
标签: c# windows win-universal-app