Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a Windows 7 Library in Windows Explorer

How do I open a Windows 7 Library like Documents, Pictures, Music, Videos and all other custom libraries from my app?

Libraries

I tried opening explorer.exe Libraries\Documents but it doesn't work.

like image 689
Elmo Avatar asked Dec 22 '22 03:12

Elmo


2 Answers

Find the AppData directory:

Dim appData As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Find the documents shortcut and open it in explorer:

For Each file As String In Directory.GetFiles(appData, "Documents.library-ms", SearchOption.AllDirectories)
    Process.Start(file)
Next
like image 162
Matt Wilko Avatar answered Dec 24 '22 02:12

Matt Wilko


Look at this to see how the most common actions are performed on Windows 7 libraries.

Edit:

The sample uses the Windows API Code Pack for Micorosoft .Net Framework [ edit 2015-09-24: previous link is dead - use this SO entry to locate the necessary Nuget packages ] (thanks MarkJ for pointing out that the link should be there).

As for David Heffernan's question ...

You use the assign the ShellLibrary object to the DefaultDirectoryShellContainer property of an Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialog (e.g. the Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog).

like image 20
AxelEckenberger Avatar answered Dec 24 '22 02:12

AxelEckenberger