出异常了 希望大神们看看什么情况
程序代码:
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { this.listView1.Items.Clear(); if (e.Node.Tag != null) { string folderPath = e.Node.ToString(); DirectoryInfo folder = new DirectoryInfo(folderPath); FileInfo[] files = null; try { files = folder.GetFiles(); } catch(UnauthorizedAccessException) { } if (files != null) { foreach (FileInfo file in files) { listView1.Items.Add(new ListViewItem(new string[] { file.Name, "文件", GetFileSize(file), file.LastWriteTime.ToString() })); } } } }