public static async Task <string> SaveTextAsync(string text)
        {
            // フォルダ名、ファイル名を作成
            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.CreateFileAsync(TextFileName,
                                                  PCLStorage.CreationCollisionOption.ReplaceExisting);

            // テキストをファイルに書き込む
            // ※冒頭に「using PCLStorage;」が必要
            await file.WriteAllTextAsync(text);

            return(file.Path);
        }
Example #2
0
        /// <summary>
        /// ユーザーデータをファイルに書き出す
        /// </summary>
        /// <param name="text">書き出す文字列</param>
        /// <returns></returns>
        static private async Task <string> SaveTextAsync(string text)
        {
            // ユーザーデータ保存フォルダー
            PCLStorage.IFolder localFolder = PCLStorage.FileSystem.Current.LocalStorage;

            // ファイルを作成、または、取得する
            PCLStorage.IFile file
                = await localFolder.CreateFileAsync(TextFileName,
                                                    PCLStorage.CreationCollisionOption.ReplaceExisting).ConfigureAwait(false);

            // テキストをファイルに書き込む
            await file.WriteAllTextAsync(text).ConfigureAwait(false);

            return(file.Path);
        }