本文介绍了我如何检查是否目录被锁定在一个TreeView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 TreeView控件的地图和填充目录中的所有文件夹,我传递变量 virtualPath
时有任何功能或属性,可以告诉我,如果该目录被堵塞或不堵塞?所以,我可以显示信息给用户说,他没有权限访问该目录。
的String [] =目录Listdirectories(virtualPath.ToString());的foreach(在目录字符串目录){ 节点=新RadTreeNode(Path.GetDirectoryName(目录的ToString())); node.Value = virtualPath +\\\\+ Path.GetFileName(目录的ToString()); parentNode.Nodes.Add(节点);}解决方案
虽然树形填充标记所需的节点有:node.Tag =LOCK
然后用
私人无效trv_SourceFolder_BeforeExpand(对象发件人,TreeViewCancelEventArgs E) { 如果(Convert.ToString(e.Node.Tag)==LOCK) e.Cancel =真; }I have a TreeView that maps and populates all the folders in a directory, I'm passing in the variable virtualPath
Is there is any function or property that can tell me if the directory is blocked or not blocked? So that I can show a message to the user saying that he does not have privileges to access the directory.
String[] directories= Listdirectories(virtualPath.ToString()); foreach (string directory in directories) { node = new RadTreeNode(Path.GetDirectoryName(directory .ToString())); node.Value = virtualPath + "\\" + Path.GetFileName(directory .ToString()); parentNode.Nodes.Add(node); }解决方案
While populating Treeview Tag the required nodes with : node.Tag="LOCK"
Then use
private void trv_SourceFolder_BeforeExpand(object sender, TreeViewCancelEventArgs e) { if (Convert.ToString(e.Node.Tag) == "LOCK") e.Cancel = true; }
更多推荐
我如何检查是否目录被锁定在一个TreeView?
发布评论