从UNC路径获取目录列表 [英] Get a Directory Listing from UNC path

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

问题描述

我想获得一个UNC路径的目录列表[
\\\\\\\ \ nbsp \ n \\ n
..]。 我知道我可以使用System.IO.DirectoryInfo对象来完成它。 但是,我必须已登录服务器。 而Systen.Net.FileWebRequest对象允许我使用提供的凭据登录,然后
传输文件。


我可以使用System.Net.FtpWebRequest执行此操作对象,但FileWebRequest对象不提供列表目录方法?


我需要做的是


  1. 连接到服务器使用提供的凭据
  2. 获取远程位置的目录列表。

有没有办法使用System.IO命名空间执行此操作,其中我可以将凭据提供给远程共享。


使用Sytem.Net命名空间是否可以这样做,


解决方案

您有两种方法可以做到这一点。


您可以使用NetShareEnum Win32 API。


netshareenum


或者用户.NET包装它,如下文所述。


Networkshares


I would like to get a directory listing of a UNC path [ \\server\share\.. ].  I know that I can do it using the System.IO.DirectoryInfo object.  However I must already be signed in to the server.  Whereas the Systen.Net.FileWebRequest object allows me to log in using provided credentials and then transfer a file.

I am able to do this using the System.Net.FtpWebRequest object, but FileWebRequest object does not provide a List Directory method?

What I need to do is

  1. Connect to server using provided credentials
  2. Get a directory listing of the remote location.

Is there a way to do this using the System.IO Namespace, where I can provice the credentials to the remote share.

Is thera a way to do this using the Sytem.Net Namespace,

解决方案

You have two ways to do this.

Either you can use NetShareEnum Win32 API.

netshareenum

Or User .NET wrapper over it as mentioned in below article.

Networkshares


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

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