【问题标题】:Fetching string from webpage into C# Form application从网页获取字符串到 C# Form 应用程序
【发布时间】:2013-02-26 19:31:00
【问题描述】:

我想建立一个网页,上面有一个简单的小字符串。没有图像,没有 CSS,没有其他任何东西。只是一个不是很长的普通字符串(最多 20 个字符)。

使用 C# Form 应用程序获取此字符串以在程序中用于各种不同目的的最佳方法是什么,例如在启动时向人们展示软件的最新版本。

【问题讨论】:

    标签: c# string webpage


    【解决方案1】:

    我自己会这样使用 System.Net.WebClient:

    using (var client = new WebClient())
    {
        string result = client.DownloadString("http://www.test.com");
        // TODO: do something with the downloaded result from the remote
    }
    

    【讨论】:

      【解决方案2】:

      尝试使用System.Net.WebClient

              string remoteUri = "http://www.myserver.com/mypage.aspx";
              WebClient myWebClient = new WebClient();
              string version = myWebClient.DownloadString(remoteUri);
      

      【讨论】:

        猜你喜欢
        • 2019-09-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多