• 0

[ VB.Net ] Special Folders


Question

I am using the line of code below to open My Computer from a button on my form, but when I click the button it opens My Documents.

System.Diagnostics.Process.Start("explorer.exe", Environment.GetFolderPath(17))

Why does it open My Documents when special folder 17 is My Computer ?

Any help much appreciated. :happy:

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

try

Environment.GetFolderPath(Environment.SpecialFolder.Personal)

Link to comment
Share on other sites

  • 0

Nope, I just tried what you suggested, the personal folder is the My Documents folder, I'm after My Computer !

The following code opens the My Documents folder which don't make sense.

Dim mycomp As String
mycomp = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer)
System.Diagnostics.Process.Start("explorer.exe", mycomp)

Any other suggestions ?

Link to comment
Share on other sites

  • 0
Heh, How on earth can it be a beta bug ? :huh:

I'm using VB.Net 2003 !!!

Not BETA, but it can be a bug... if it's final it doesn't mean it's bug free, like Application.EnableVisualStyles() has many problems at times, and i prefer to still stick with using my manifest file.

Link to comment
Share on other sites

  • 0

Well, okay, think about what you're actually doing here. The prototype for Process.Start is:

Process.Start(filename,arguments)

Arguments is a string, but you're passing it SpecialFolders.MyComputer, which would translate to either "System.Enum" or "17" as a string, neither of which explorer.exe takes as a parameter.

You may not be able to open My Computer in an explorer window from the command line, since "My Computer" is not an actual path on the system. (I couldn't find any way to do this)

Link to comment
Share on other sites

  • 0

The command line to open an explorer window showing My Computer is:

%systemroot%\explorer.exe /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

or, without the tree-view pane to the left:

%systemroot%\explorer.exe ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

Link to comment
Share on other sites

  • 0

Yeah dannysmurf perhaps that is the case because as you say My Computer is not an actual folder on the system.

Thanks Gumboot, I may be able to do it using that info, I'll try later and let you know how I get on.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.