We need a SpecialFolder.ThisPC for WIndows

Therea re many times when we need to offer the user the highest level selection point on a Windows system (think root on macOS or Linux). This is to focus on showing the user all of the volumes mounted on the system, rather than just some subfolder.

Since there is no simple way to set the InitialFolder of an OpenFileDialog to “This PC” without serious coding gymnastics, it would be nice to have such an option in the SpecialFolder class.

If someone has a method for extending SpecialFolder or a separate method for defining it, I would be happy to create a proper Class extension and share it. Or, am I off to Feature Request dead zone?

1 Like

What folderitem would that return, since This PC is a virtual folder?


should be the root volume (this PC)

Drive zero is the boot drive

The root volume is C:
“This PC” is where you can see favourites, all drives, discovered network shares, etc.

Not the same things.

As Arnaud said, such place does not exist, it is a snapshot emulated via coding gymnastics as you said. But you can move the explorer to there using this “path” ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

It is so Windows centric that such thing does not deserve a “SpecialFolder.ThisComputer”

Create you own function ThisComputerFolder as

Public Function ThisComputerFolder() As FolderItem
  #If TargetWindows Then
    Return New FolderItem("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", FolderItem.PathModes.Native)
    Return Nil
End Function


Var dlg As New SelectFolderDialog
dlg.ActionButtonCaption = "Select"
dlg.Title = "This Computer 'folder'"
dlg.PromptText = "Pick a place"

dlg.InitialFolder = ThisComputerFolder()

Var f As FolderItem
f = dlg.ShowModal
If f <> Nil Then
  // Use the folderitem here
  // User cancelled
End If

Is this tested… does… does this work? That’s really cool.

For Win10, yes. But the same behavior should follow from Win7 and beyond.


That is really cool, thank you for sharing! I may need to sneak that into some projects of mine :wink:


That’s the point - That virtual location is the only location that would show a user all mounted drives on the system (which is what I’m in need of)

That is exactly what I need!

Bingo! Thank’s Rick.

1 Like

That is exactly what is needed:

#If TargetWindows
  oDlg.InitialFolder = GetFolderItem("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", FolderItem.PathTypeNative)
#ElseIf TargetMacOS
  oDlg.InitialFolder = GetFolderItem("/Volumes", FolderItem.PathTypeNative)
  oDlg.InitialFolder = GetFolderItem("/", FolderItem.PathTypeNative)


BTW: This also works with the CLSID {208D2C60-3AEA-1069-A2D7-08002B30309D} to show the network environment.



// For My Computer
New FolderItem("::{20d04fe0-3aea-1069-a2d8-08002b30309d}", FolderItem.PathModes.Native)

// For My Documents
New FolderItem("::{450d8fba-ad25-11d0-98a8-0800361b1103}", FolderItem.PathModes.Native)

// For My Network places (warning, may be slow to show up)
New FolderItem("::{208d2c60-3aea-1069-a2d7-08002b30309d}", FolderItem.PathModes.Native)

1 Like

Another way …


Should return “C:” (without the backslash.) Assuming C is the system drive, which it is unless it has been changed.


What do various properties show when examining that folderitem from within Xojo? I can’t use a Windows OS tonight to check.

The proper ones. You will see later when you do your tests.

1 Like

Thanks, your screenshot tells me exactly what I wanted to know.

1 Like