如何纠正错误“非法形式的路径” [英] How to correct error "Path of ilegal form"

查看:69
本文介绍了如何纠正错误“非法形式的路径”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用树视图,我希望能够在单击该文件夹中的文件后获取文件夹中的所有文件。

我正在使用此代码:

I am using a treeview, and I want to be able to get all the files inside a folder after I click a file inside that folder.
I am using this code:

//I am getting path has an ilegal form in the next line
//I also tried this statement inside the foreach, but with no luck
(Path.GetFullPath(Path.GetFileName(trwFileExplorer.SelectedNode.Name))))
//This was the other thing I tried

path.Text = Path.GetDirectoryName(trwFileExplorer.SelectedNode.Name);
//and I am getting the same error here inside the foreach            
            foreach (string file in Directory.GetFiles(path.Text))
                {
                    media = player.newMedia(Path.GetFullPath(Path.GetFileName(file.ToString())));
                    playlist.appendItem(media);
                    //path.Text = Path.GetFullPath(Path.GetFileName(file.ToString()));
                }





如何解决这个问题?

谢谢!



How can I fix this?
Thanks!

推荐答案

调试并检查运行时 trwFileExplorer.SelectedNode.Name 的值。您确定要使用treeview Name属性吗?它应该是文本,具体取决于您如何绑定数据和您的要求。
Debug and check what is the value you get as trwFileExplorer.SelectedNode.Name in runtime. Are you sure that you want treeview Name property? it should be Text or Value depending on how you bind data and your requirements.


这篇关于如何纠正错误“非法形式的路径”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆