从UNC路径获取文件 [英] Get Files From UNC Path

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

问题描述





我想知道目录中存在的所有文件。但目录在网络中,即\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 目录,有 6个文件礼物。



如何从中获取所有 6个文件名上面提到的 UNC路径在C#中?



任何建议。



问候,

AJ83

Hi,

I would like to know what all files are present in the directory. But Directory is in network i.e. "\\abc\Test\AllFiles".

In "ÄllFiles" directory, there are 6 files presents.

How to get all 6 files name from UNC Path mentioned above in C#?

Any Suggestion.

Regards,
AJ83

推荐答案

var files = System.IO.Directory.GetFiles(@"\\abc\Test\AllFiles");



会为你做的伎俩(给你一个文件名数组)。



编辑 - 更新以考虑原始问题中未包含的相当重要的信息(这是作为网络应用程序运行)



要从Web服务访问UNC路径 - 其中一种方法是模拟 - 这就是全部使Web应用程序作为网络用户运行,可以访问网络路径。

http://msdn.microsoft.com/en-us/library/xh507fc5(v = vs.100).aspx [ ^ ]

请仔细阅读这样做的安全隐患。


Will do the trick for you (give you an array of file names).

Edit - Update to take in to account of the rather important piece of information that wasn't included in the original question (This is running as a web app)

To access a UNC path from a web service - one of the ways of doing this is impersonation - this allows the web app to run as a network user that can be given access to the network path.
http://msdn.microsoft.com/en-us/library/xh507fc5(v=vs.100).aspx[^]
Please read carefully about the security implications of doing this.


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

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