views:

32

answers:

1

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?

By the way, there's a solution to this problem in Java using ShellFolders. This is basically what I need in .NET as well.

+2  A: 

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.

Philip Rieck
And exactly the "MyComputer" case is the problem. The only way would be to read the drives and build this node myself. But this seems to be not generic.
tigger
Added a pointer to a project on codeplex that may do what you want.
Philip Rieck
Thanks! That's exactly what I was looking for!
tigger