private void Form1_Load(object sender, EventArgs e) { DriveInfo[] Drives = DriveInfo.GetDrives(); string[] directories; ICatalog Current; TreeNode node; for (int i = 0; i < Drives.Length; i++) { treeView1.Nodes.Add(Drives[i].Name); if (Drives[i].DriveType == DriveType.Removable || Drives[i].DriveType == DriveType.CDRom) continue; FolderObj fo = new FolderObj(); Current = (ICatalog)fo; Current.Initialize(Drives[i].Name); Current.ReloadFiles(); int n = Current.GetDirectoriesCount(); if (n == 0) continue; directories = new string[n]; for (int j = 0; j < n; j++) directories[j] = Current.GetDirectoryName(j); foreach (var directory in directories) { node = new TreeNode(directory); node.ImageIndex = 0; treeView1.Nodes[i].Nodes.Add(node); } } for(int i=0; i < treeView1.Nodes.Count; i++) { DriveInfo di = new DriveInfo(treeView1.Nodes[i].Text); if (di.DriveType == DriveType.Fixed) { treeView1.SelectedNode = treeView1.Nodes[i]; return; } } }
private void OpenDir(string path) { ListViewItem lvi; FolderObj fo = new FolderObj(); IFSObject temp = null; Current = (ICatalog)fo; Current.Initialize(path); Current.ReloadFiles(); listView1.Items.Clear(); string[] files; int n = Current.GetFileSystemEntriesCount(); if (n == 0) return; files = new string[n]; for (int i = 0; i < n; i++) files[i] = Current.GetFileSystemEntryName(i); for(int i=0; i < files.Length; i++) { temp = Current.GetFile(i); if (temp.isDir() == 1) lvi = new ListViewItem(files[i], 0); else lvi = new ListViewItem(files[i], 1); listView1.Items.Add(lvi); } textBox1.Text = path; }