[英]How to address home directory and “my computer” in c# TreeView
I am making a file system TreeView. 我正在制作一个文件系统TreeView。 I want the initial four items to be
我想要最初的四个项目
+Computer +电脑
+Desktop +桌面
+My Documents +我的文件
+C:\\ + C:\\
These will all be pre-populated so that when the + is clicked, the subdirectories appear and are immediately themselves populated. 这些都将被预先填充,以便在单击+时,子目录出现并立即自行填充。 Works great for C:\\ -- just like windows explorer.
非常适合C:\\ - 就像Windows资源管理器一样。 But the other three just show as names.
但其他三个只是作为名字显示。 They clearly don't relate to the actual filesystem locations.
它们显然与实际的文件系统位置无关。 How do I add the other three filesystem locations?
如何添加其他三个文件系统位置? I tried:
我试过了:
TreeNode my_computer = new TreeNode("Computer");
TreeNode desktop = new TreeNode(@"%UserProfile%\Desktop");
TreeNode c_drive = new TreeNode(@"C:\");
TreeNode my_documents = new TreeNode(@"%UserProfile%\My Documents");
and also without %UserProfile%. 并且没有%UserProfile%。 Neither work.
都没有工作。
You may want to look into Environment.SpecialFolder
enumeration: 您可能希望查看
Environment.SpecialFolder
枚举:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.