解决清单文件的UnauthorizedAccessException问题 [英] Solving UnauthorizedAccessException issue for listing files

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

问题描述

列出系统驱动器以外的驱动器中的所有文件会引发 UnauthorizedAccessException .

Listing all files in a drive other than my system drive throws an UnauthorizedAccessException.

我该如何解决这个问题?

How can I solve this problem?

是否有一种方法可以授予我的应用程序所需的访问权限?

Is there a way to grant my application the access it needs?

Directory.GetFiles("S:\\", ...)

推荐答案

我解决了这个问题.不是真的,但至少是来源.

I solved the problem. Not really but at least the source.

是导致异常的SearchOption.AllDirectories选项.

It was the SearchOption.AllDirectories option that caused the exception.

但是当我仅使用Directories.GetFiles列出即时文件时,它就可以工作.

But when I just list the immediate files using Directories.GetFiles, it works.

这对我来说已经足够了.

This is good enough for me.

有什么方法可以解决递归列表问题?

Any way to solve the recursive listing problem?

这篇关于解决清单文件的UnauthorizedAccessException问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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