获取远程服务器的目录 [英] Get directories of remote Server

查看:216
本文介绍了获取远程服务器的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取远程服务器的所有目录.

I'm trying to get all directories of a remote server.

例如: path: "\\Servename\folder"-有效!

path: "\\Servename"-错误

我尝试过:

DirectoryInfo dir = new DirectoryInfo (@"\\SERVERNAME"); <- Error happens here
//Get Directories from \\SERVERNAME
DirectoryInfo[] dirInfos = dir.GetDirectories();

错误:ERROR: The UNC path should be of the form \\server\share

推荐答案

原因是您需要读取可用的共享,而不仅仅是目录,因为评论已得到答复.

The reason is that you need to read available shares and not just the directories, as the comments answered.

但是,获取服务器上所有可用共享的列表会有些复杂,已经在另一个问题中得到了回答:

However getting the list of all available shares on a server is a bit more complicated, it was already answered in a different question: Get a list of all UNC shared folders on a local network server

投票最多的答案是网络共享和UNC路径

这篇关于获取远程服务器的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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