DirectoryNotFoundException was unhandled Could not find a part of the path 'D:\Works\Nando\C#\Apps\Media Player\1\PMedia Player\PMedia Player\bin\Release\Release\Video\1\002. Configuring the Layout of Visu.mp4'. //which is the full path of the selected file in the treeview
private void ListDirectory() { list.Nodes.Clear(); var rootDirectoryInfo = new DirectoryInfo(Directory.GetCurrentDirectory().ToString()); list.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo)); } private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo) { var directoryNode = new TreeNode(directoryInfo.Name); foreach (var directory in directoryInfo.GetDirectories()) directoryNode.Nodes.Add(CreateDirectoryNode(directory)); foreach (var file in directoryInfo.GetFiles()) directoryNode.Nodes.Add(new TreeNode(file.Name)); return directoryNode; } private void list_AfterSelect(object sender, TreeViewEventArgs e) { WMPLib.IWMPPlaylist playlist = player.playlistCollection.newPlaylist("media_playlist"); WMPLib.IWMPMedia media; //player.close() DirectoryInfo dir = new DirectoryInfo(list.SelectedNode.FullPath.ToString()); if (list.SelectedNode.FullPath.Length!=0) { foreach (var file in dir.GetFiles()) { media = player.newMedia(Path.GetFullPath(Path.GetFileName(file.ToString()))); playlist.appendItem(media); path.Text=Path.GetFullPath(Path.GetFileName(file.ToString())); } list.Visible = false; player.currentPlaylist = playlist; player.Ctlcontrols.play(); }else{ MessageBox.Show("Directory not found!"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)