void listViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListViewItem item = e.Source as ListViewItem; DirectoryEntry entry = item.DataContext as DirectoryEntry; if (entry.Type == EntryType.Dir) { subEntries.Clear(); foreach (string s in Directory.GetDirectories(entry.Fullpath)) { DirectoryInfo dir = new DirectoryInfo(s); DirectoryEntry d = new DirectoryEntry( dir.Name, dir.FullName, "<Folder>", "<DIR>", Directory.GetLastWriteTime(s), "Images/folder.gif", EntryType.Dir); subEntries.Add(d); } foreach (string f in Directory.GetFiles(entry.Fullpath)) { FileInfo file = new FileInfo(f); DirectoryEntry d = new DirectoryEntry( file.Name, file.FullName, file.Extension, file.Length.ToString(), file.LastWriteTime, "Images/file.gif", EntryType.File); subEntries.Add(d); } listView2.DataContext = subEntries; } }
void Window1_Loaded(object sender, RoutedEventArgs e) { foreach (string s in Directory.GetLogicalDrives()) { DirectoryEntry d = new DirectoryEntry(s, s, "<Driver>", "<DIR>", Directory.GetLastWriteTime(s), "Images/dir.gif", EntryType.Dir); entries.Add(d); } this.listView1.DataContext = entries; }