【发布时间】:2015-12-07 05:46:53
【问题描述】:
我正在尝试从服务器读取一些数据以获取内置更新功能,但出现编译时错误。有什么办法可以解决这个问题吗?我需要这个来检查用户是否有可用的互联网连接,如果没有则跳过更新检查。 (除非 .Net 4.5 中有更可靠的方法)
WebClient client = new WebClient();
try
{
Stream stream = client.OpenRead("http://repo.itechy21.com/updatematerial.txt");
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
StreamReader reader = new StreamReader(stream); // <-- error here
String content = reader.ReadLine();
错误:
当前上下文中不存在流
【问题讨论】:
-
How to use downvotes 你会关心为什么?
-
iTechy,该主题 When justiffiable to downvote 进入更多细节,以及要求 cmets 反对投票的讨论 - meta.stackoverflow.com/questions/250177/…。 TL;DR - 没有研究显示 => 反对票。
-
感谢您对此进行扩展 :)
标签: c# .net webclient filestream