i want to read a file by its Uri, and ask the user to store the file. This has to be done using Silverlight.
Ive tried the following, and it didnt work.开发者_Python百科.
client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
private void Build_Log_Click(object sender, RoutedEventArgs e)
{
Uri uri = new Uri("http:***.log");
client.OpenWriteAsync(uri);
}
private void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
bool? result = textDialog.ShowDialog();
if (result == true)
{
var text = e.Result;
System.IO.Stream fileStream = textDialog.OpenFile();
StreamWriter sw = new System.IO.StreamWriter(fileStream);
sw.Write(text);
sw.Flush();
sw.Close();
}
}
As from my comment, client.OpenWriteAsync should be client.OpenReadAsync ( yes this is a indiscriminated way of gaining some points :) )
精彩评论