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);
        }
Beispiel #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);
        }
Beispiel #3
0
        /// <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());
        }