2011-08-11 11 views

答えて

1

ファイルをダウンロードしてIsolated Storageにコピーできます。

このような何か...

 private void DownloadFiles() 
    { 
     var wc = new WebClient(); 
     wc.OpenReadCompleted += WcOpenReadCompleted; 
     wc.OpenReadAsync(new Uri("http://myserver/myfile.file", UriKind.Absolute)); 
    } 

    public static void CopyStream(Stream input, Stream output) 
    { 
     var buffer = new byte[32768]; 
     while (true) 
     { 
      int read = input.Read(buffer, 0, buffer.Length); 
      if (read <= 0) 
       return; 

      output.Write(buffer, 0, read); 
     } 
    } 

    private static void WcOpenReadCompleted(object sender, OpenReadCompletedEventArgs e) 
    { 
     using (IsolatedStorageFile userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication()) 
     { 
      var isolatedStorageFileStream = userStoreForApplication.CreateFile("mylocalfilename"); 

      using (isolatedStorageFileStream) 
      { 
       CopyStream(e.Result, isolatedStorageFileStream); 
      } 
     } 
    } 
+0

は非常に多くのuをありがとう!それはうまく動作します! – masiboo

関連する問題