[英]How to address home directory and “my computer” in c# TreeView
我正在制作一個文件系統TreeView。 我想要最初的四個項目
+電腦
+桌面
+我的文件
+ C:\\
這些都將被預先填充,以便在單擊+時,子目錄出現並立即自行填充。 非常適合C:\\ - 就像Windows資源管理器一樣。 但其他三個只是作為名字顯示。 它們顯然與實際的文件系統位置無關。 如何添加其他三個文件系統位置? 我試過了:
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");
並且沒有%UserProfile%。 都沒有工作。
您可能希望查看Environment.SpecialFolder
枚舉:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.