有没有办法用PCLStorage模块读取PCL项目中的嵌入式JSON文件?我到处寻找,但找不到与此事有关的样本.
编辑:PCLStorage链接:https://github.com/dsplaisted/pclstorage
你需要这样的东西:
public static async Task<string> ReadFileContent(string fileName, IFolder rootFolder)
{
ExistenceCheckResult exist = await rootFolder.CheckExistsAsync(fileName);
string text = null;
if (exist == ExistenceCheckResult.FileExists)
{
IFile file = await rootFolder.GetFileAsync(fileName);
text = await file.ReadAllTextAsync();
}
return text;
}
Run Code Online (Sandbox Code Playgroud)
使用:
IFolder rootFolder = FileSystem.Current.LocalStorage;
IFolder myCoolFolder = await rootFolder.CreateFolderAsync("MyCoolForler", CreationCollisionOption.OpenIfExists);
string fileContent = await this.ReadFileContent("MyCoolFile.txt", myCoolFolder);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4457 次 |
| 最近记录: |