2
我想弄清楚如何讀寫存儲在應用程序隔離存儲中的參數。在獨立存儲,便攜式類庫中緩存變量的方式
現在即時建立一個Windows Phone應用程序,但因爲我想要一個win8應用程序,我想我可以在便攜式類庫項目中做到這一點,並發現這個真棒PCLStorage。
我的緩存類看起來ATM像這樣用於存儲PARAMS:
public async static Task<string> GetParam(string name)
{
IFolder rootfolder = FileSystem.Current.LocalStorage;
IFolder folder = await rootfolder.GetFolderAsync("isostore");
IFile file = await folder.GetFileAsync(name);
return await file.ReadAllTextAsync();
}
public async static void SaveParam(string name, string param)
{
IFolder rootfolder = FileSystem.Current.LocalStorage;
IFolder folder = await rootfolder.CreateFolderAsync("isostore", CreationCollisionOption.OpenIfExists);
IFile file = await folder.CreateFileAsync(name, CreationCollisionOption.ReplaceExisting);
await file.WriteAllTextAsync(param);
}
寫入部件是好,它覆蓋,如果有任何。它的閱讀部分就是問題所在。 IFile和IFolder沒有任何.Exists
函數(???),如果我在保存之前調用Get,它會返回什麼?