0

グループ メッセージを送信できる SMS 作成タスクを作成しようとしています。ユーザーは分離されたストレージ ファイルに電話番号を追加し、そこから番号を取得するつもりです。

そこから電話番号を取得するにはどうすればよいですか?
また、分離ストレージ ファイルから番号を削除する方法を教えてください。

分離ストレージ ファイルのコードは次のとおりです。

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
    string fileName = "SOS Contacts.txt";
    using (var isoStorage = IsolatedStorageFile.GetUserStoreForApplication())
    {
        // we need to check to see if the file exists
        if (!isoStorage.FileExists(fileName))
        {
            // file doesn't exist...time to create it.
            isoStorage.CreateFile(fileName);
        }
        // since we are appending to the file, we must use FileMode.Append

        using (var isoStream = new IsolatedStorageFileStream(fileName, FileMode.Append, isoStorage))
        {
            // opens the file and writes to it.
            using (var fileStream = new StreamWriter(isoStream)
            {
                fileStream.WriteLine(PhoneTextBox.Text);
            }
        }
       // you cannot read from a stream that you opened in FileMode.Append.  Therefore, we need
       //   to close the IsolatedStorageFileStream then open it again in a different FileMode.  Since we
       //   we are simply reading the file, we use FileMode.Open

       using (var isoStream = new IsolatedStorageFileStream(fileName, FileMode.Open, isoStorage))
       {
           // opens the file and reads it.
           using (var fileStream = new StreamReader(isoStream))
           {
               ResultTextBox.Text = fileStream.ReadToEnd();
           }
       }
   }
}
4

1 に答える 1

0

Application Settingsを使用Isolated Storageしてデータを保存および取得しようとしましたか。に保存するとSettings、アプリケーションからどこからでも取得できます。

完璧なサンプルはこれでしょう。

次のサンプルは msdn からのものです。

http://code.msdn.microsoft.com/windowsapps/Using-Isolated-Storage-fd7a4233

それが役に立てば幸い!

于 2014-08-13T07:35:52.713 に答える