How to get the virtual "Desktop" root as shown in the Windows Explorer?
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.
精彩评论