我正在为xamarin编写跨平台应用程序,适用于Android和iOS,我需要将一些文本文件保存到本地存储。我正在使用PCL存储,但每当我将鼠标悬停在任何PCLStorage代码上时,它都会显示“MyApplication.Android:available,MyApplication.iOS not available”。如何使用PCLStorage在两个平台上存储文件?或者还有另一种方法可以做到这一点吗?这是我的一些代码的例子:
public async Task CreateRealFileAsync(string filename, string filebody)
{
// get hold of the file system
IFolder rootFolder = FileSystem.Current.LocalStorage;
// create a folder, if one does not exist already
IFolder folder = await rootFolder.CreateFolderAsync("DadAppFiles", CreationCollisionOption.OpenIfExists);
// create a file, overwriting any existing file
IFile file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
// populate the file with some text
await file.WriteAllTextAsync(filebody);
}