我如何检查是否目录被锁定在一个TreeView?

编程入门 行业动态 更新时间:2024-10-25 17:20:51
本文介绍了我如何检查是否目录被锁定在一个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?

本文发布于:2023-06-04 19:06:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/503328.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目录   TreeView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!