0

こんにちは、私は Windows Phone 開発の新人です。現在オンライン アプリケーションに取り組んでいますが、URL から json ファイルをダウンロードしてローカル ストレージにテキスト ファイルとして保存する方法と、そこからテキストを読み取る方法に問題があります。解析を実行します。

using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if(isf.FileExists("file.txt")) { using (IsolatedStorageFileStream rawstream = isf.OpenFile("file.txt", System.IO.FileMode.Open)) { StreamReader 読み取り = 新しい StreamReader(rawstream); 結果 = read.ReadLine(); read.Close(); } } } MessageBox.Show("完了および既読" + 結果); }

4

1 に答える 1

0

あなたがしたいのは、jsonをダウンロードして解析することです。

jsonファイルをダウンロードするには

private void GetAlbums()
{
    WebClient webClient = new WebClient();
    Uri uri = new Uri(dataFeed, UriKind.Absolute);
    webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(AlbumsDownloaded);
    webClient.DownloadStringAsync(uri);
}

このファイルを解析して読み取るには

  public void AlbumsDownloaded(object sender,   DownloadStringCompletedEventArgs e)
  {
        // Deserialize JSON string to dynamic object
        IDictionary<string, object> json = (IDictionary<string, object>)SimpleJson.DeserializeObject(e.Result);
        // Feed object
        IDictionary<string, object> feed = (IDictionary<string, object>)json["feed"];
}

この記事はとても役に立ちました。作業を楽にするために、このサンプルを 1 時間実行する必要があります。

http://www.developer.nokia.com/Community/Wiki/Picasa_Image_Gallery_with_JSON_in_WP7

于 2013-06-30T11:05:56.483 に答える