/// <summary> /// ユーザーデータをファイルから読み取る /// </summary> /// <returns></returns> static private async Task <string> LoadTextAsync() { // ユーザーデータ保存フォルダー PCLStorage.IFolder localFolder = PCLStorage.FileSystem.Current.LocalStorage; ExistenceCheckResult res = await localFolder.CheckExistsAsync(TextFileName).ConfigureAwait(false); if (res == ExistenceCheckResult.NotFound) { return(null); } // ファイルを取得する PCLStorage.IFile file = await localFolder.GetFileAsync(TextFileName).ConfigureAwait(false); // テキストファイルを読み込む return(await file.ReadAllTextAsync().ConfigureAwait(false)); }
public static async Task <string> LoadTextAsync() { // フォルダ名、ファイル名を作成 var SubFolderName = "GitUserData"; var TextFileName = "gitUser.txt"; // ユーザーデータ保存フォルダー PCLStorage.IFolder localFolder = PCLStorage.FileSystem.Current.LocalStorage; // サブフォルダーを作成、または、取得する PCLStorage.IFolder subFolder = await localFolder.CreateFolderAsync(SubFolderName, PCLStorage.CreationCollisionOption.OpenIfExists); // ファイルを取得する PCLStorage.IFile file = await subFolder.GetFileAsync(TextFileName); // テキストファイルを読み込む // ※ファイル冒頭に「using PCLStorage;」が必要 return(await file.ReadAllTextAsync()); }