0
我與XmlSerializer的,每一個項目被添加到我的列表時,我調用保存方法工作:爲什麼我的文件沒有保存? XmlSerializer的WinRT的中
async public void save(List<string> eingabe)
{
var serializer = new XmlSerializer(typeof(List<string>));
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile =
await storageFolder.CreateFileAsync(speicherPfad, CreationCollisionOption.ReplaceExisting);
var file = await sampleFile.OpenAsync(FileAccessMode.ReadWrite);
serializer.Serialize(file.AsStreamForWrite(), eingabe);
file.Dispose();
}
當應用程序啓動時我稱之爲加載方法:
public async Task<List<string>> load()
{
List<string> ausgabe = new List<string>();
XmlSerializer serializer = new XmlSerializer(typeof(List<string>));
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.CreateFileAsync(speicherPfad, CreationCollisionOption.ReplaceExisting);
var file = await sampleFile.OpenAsync(FileAccessMode.Read);
List<string> speicher = (List<string>)serializer.Deserialize(file.AsStreamForRead());
file.Dispose();
return speicher;
}
問題:負載方法,文件始終是空的(大小= 0),我不知道爲什麼
哦,我的上帝,這是多麼愚蠢的錯誤。 – gurehbgui
我們都去過那裏。 :) –