public List <ListViewItem <FileSystemInfo> > GetItems(FileSystemInfo listViewCurrent) { DirectoryInfo current = Modal == null ? (DirectoryInfo)listViewCurrent : (DirectoryInfo)Modal.ListView.Current; try { return(current .GetFileSystemInfos() .Select( lvi => new ListViewItem <FileSystemInfo>( lvi, lvi.Name, lvi is DirectoryInfo ? "<dir>" : lvi.Extension, lvi is FileInfo file ? Utility.BytesToStringAsNormalizedSize(file.Length) : "")) .ToList()); } catch (UnauthorizedAccessException) { var parent = Directory.GetParent(listViewCurrent.FullName) ?? new DirectoryInfo(Path.GetPathRoot(listViewCurrent.FullName)); foreach (var panel in Panels) { if (panel.Focused) { panel.Current = parent; } } var popup = new PopupMessage(this, "Access denied.", "Error"); popup.Render(); return(GetItems(parent)); } }
static void Main(string[] args) { Console.CursorVisible = false; Console.WindowHeight = 50; Console.BufferHeight = Console.WindowHeight; Console.BufferWidth = Console.BufferWidth; PanelSet panelSet = new PanelSet(2); panelSet.RefreshScreen(); while (true) { var key = Console.ReadKey(); try { panelSet.Update(key); } catch (Exception ex) { var popup = new PopupMessage(panelSet, $"This operation cannot be performed.\r\n{ex.Message}", "Error"); popup.Render(); } panelSet.Render(); } }