开发者

How to get the virtual "Desktop" root as shown in the Windows Explorer?

开发者 https://www.devze.com 2023-01-17 02:32 出处:网络
I need to create a directory tree similar to the one shown in the Windows Explorer. Using SpecialFolders doesn\'t help since these folders are physical folders. So, is there any representation of thes

I need to create a directory tree similar to the one shown in the Windows Explorer. Using SpecialFolders doesn't help since these folders are physical folders. So, is there any representation of these virtual folders like "Desktop", "Computer" or "Network" in .NET?

开发者_如何学CBy the way, there's a solution to this problem in Java using ShellFolders. This is basically what I need in .NET as well.


Try

Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

Note that the SpecialFolder enumeration allows you to specify many "special" folders. Passing in the 'MyComputer' value will return an empty string, however - there is no actual path specified for it.

If you need "MyComputer" you may need to do some interop work. See this project on codeplex, which gets some shell folders (including My Computer) this way.

0

精彩评论

暂无评论...
验证码 换一张
取 消