我已经看到了这个,但还没有完全解决这个问题。当我阅读所有查找并包含文件夹时,编译器 meg 会抛出关于 Unauthorized 的异常。错误抛出编译器:
访问路径 F:\System Volume information \ 被拒绝
我的代码是
private void toolStripButton8_Click(object sender, EventArgs e)
{
try
{
Uri _urii = new Uri(toolStripTextBox1.Text);
// MessageBox.Show(_urii.Host);
string _sthost = _urii.Host;
string aa = "F:\\" + _sthost + " ";
string[] _file = Directory.GetFiles("F:\\", "*.txt", SearchOption.AllDirectories); //Exception here create
foreach (var item in _file)
{
MessageBox.Show(item.Length.ToString());
我的问题是F盘没有系统卷信息文件夹.. 为什么抛出这种类型的异常?