我想通过其Uri读取文件,并要求用户存储该文件。这必须使用Silverlight完成。
我尝试过以下内容,但它没有用。
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();
}
}
答案 0 :(得分:1)
从我的评论中,client.OpenWriteAsync应该是client.OpenReadAsync(是的,这是获得一些积分的不分青红皂白的方式:))