列表中的文件和远程Web的服务器文件夹(HTTP) [英] List the files and folder on a remote web sever (http)
本文介绍了列表中的文件和远程Web的服务器文件夹(HTTP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想列出的文件在远程服务器(HTTP)。请咨询我关于一个控制台应用程序可能的选择。
I would like to list files on remote sever (HTTP). Please, advice me on possible options for a console application.
推荐答案
您可以使用的 Web客户端
类调用你的服务器,读取文件/目录列表和浏览目录递归。
You can use the WebClient
class to call your server, read the file/directory lists and navigate through the directories recursively.
下面是基本使用Web客户端的:
Here is the basic use of WebClient:
WebClient client = new WebClient ();
Stream data = client.OpenRead ("http://example.com");
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd ();
// At this point, the variable s contains the returned webpage
另一种选择,其可以是更适合的,它以使用 HTML敏捷性包的 - 你可以使用 WebHtml
对象,直接从网络上获取的HTML,然后用它查询的XPath
的语法。
Another option, which may be more suitable, it to use the HTML Agility Pack - you can use the WebHtml
object to retrieve HTML directly from the web and then query it using XPath
syntax.
这篇关于列表中的文件和远程Web的服务器文件夹(HTTP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文