Open the Windows 7 Library in Windows Explorer

How to open a Windows 7 library, for example Documents , Pictures , Music , Videos and all other user libraries from my application?

Libraries

I tried to open explorer.exe Libraries\Documents , but this will not work.

+4
source share
6 answers

Find the AppData directory:

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

Find the document shortcut and open it in Explorer:

 For Each file As String In Directory.GetFiles(appData, "Documents.library-ms", SearchOption.AllDirectories) Process.Start(file) Next 
+5
source

See this one to find out how the most common actions are performed in Windows 7 libraries.

Edit:

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

Regarding the question of David Heffernan ...

You are using the ShellLibrary object ShellLibrary for the ShellLibrary property for Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialog (e.g. Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog ).

+4
source

Libraries are stored in C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Libraries and has the extension .library-ms , so Documents will be Documents.library-ms

+1
source

The Windows API Code Code provides managed APIs for interacting with Windows 7 libraries. I think this may help.

+1
source

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

Replace MyDocuments with what you need, look in the listing to see which ones are.

0
source

This refers to the comments in the LostInLib post, as the explanation is too long to put a comment.

You need to understand the difference between libraries and the document folder, because they are not the same thing. C: \ Users \ USERNAME \ Documents - the default document folder C: \ Users \ USERNAME \ AppData \ Roaming \ Microsoft \ Windows \ Libraries \ Documents.library-ms - this is a library called Documents, the library is an index of all the locations you add to him, it does not need to be associated with C: \ Users \ USERNAME \ Documents, for example, on my network. I have set the value \ server \ users \ USERNAME, so when users go to the document library on the Start menu, they are redirected to the server share. You can also have more than one place in the library so that I can use my LOCAL documents and my document server, so when I went to my document library, they displayed both folders in one place, so they would look like in the same folder of mine documents.

So, assuming my documents will be here, not very good, since it should not be C: \ Users \ USERNAME \ Documents, just like libraries, it should not be here C: \ Users \ USERNAME \ AppData \ Roaming \ Microsoft \ Windows \ Libraries \ Documents.library ms if you redirect your appdata folder, for example, as on the network, your libraries can also be here: \ Server \ users \ USERNAME \ AppData \ Roaming \ Microsoft \ Windows \ Libraries \ Documents .library ms

0
source

Source: https://habr.com/ru/post/1392887/


All Articles