从Web文件夹C#获取文件和目录列表 [英] Get list of files and directories from web folder C#

查看:487
本文介绍了从Web文件夹C#获取文件和目录列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我从网址获取目录和文件列表时遇到问题。



位置是:http://www.myservername.com/documents/



通过使用单点登录,我可以使用Windows资源管理器浏览此文件夹没有问题。技术上,这个文件夹位于我们公司网络和Intranet页面的后面,我们通过浏览器访问文档。



DirectoryInfo不能使用这种类型的链接。 />


你可以帮这个吗?



问候,

Aleksandar



我尝试了什么:



我用Google搜索了这个问题几个小时我看到的一个解决方案是使用Httprequest,但我找不到它,虽然我添加了System.Web引用和dll。

Hi all,

I have an issue getting list of directories and files from web location.

location is: http://www.myservername.com/documents/

By using Single-Sign-On, I can browse this folder by using Windows Explorer with no problem. Technicaly, this folder is in the back of our corporate network and Intranet pages where we access documentation via Browser.

DirectoryInfo is not working with this types of links.

Can you help with this one?

Regards,
Aleksandar

What I have tried:

I have googled this question for a couple of hours. One of solutions I saw is to use Httprequest but I cannot find it, although I added System.Web reference and dll.

推荐答案

DirectoryInfo使用路径而不是URL。 />
而不是使用http:// www ....方法尝试使用
DirectoryInfo uses paths not URLs.
Instead of using the http://www.... approach try using the
99.99.99\sharename\foldername

方法,其中99.99.99是该服务器的IP地址。

或尝试

approach where 99.99.99 is the IP address of that server.
or try

\\myservername.com\documents\...

(如果文件是共享的名称)

(if documents is the name of the share)


Tnx Chill60!正是我在寻找什么。非常简单和优雅,我必须动态地将链接转换为路径,但是,我看到的最简单的方式。



非常感谢。
Tnx Chill60! Exactly what I was looking for. Very simple and elegant, I must convert link to path dynamically, but however, simplest way I saw yet.

Thank you very much.


这篇关于从Web文件夹C#获取文件和目录列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆