How to get the target path for the UserName / My Pictures folder?

How can I get the target path for the My Pictures folder in Window Seven? In Seven, we have two folders: "Pictures" and "My Pictures" (second link to the first). Therefore, in my application, I show both folders and I want to understand that the My Pictures folder is only cut. Which attribute should I use or in another way?

+4
source share
2 answers

Pictures on Windows 7 is part of the Library. The Windows API Code Code contains several useful libraries for managing Windows 7 libraries.

and My pictures is part of a special folder that you can use Environment.SpecialFolder . If you focus only on Windows 7, I would recommend that you check the Windows API code code, which has many new features that you can use in your application. Extensive library support and folder dialog selection, etc.

+2
source

Even if you need to target both Windows 7 and older versions, you can use the Code Pack, but you will need to do some checking to make sure the libraries exist. Consider these three lines from ThumbnailToolbarDemoWinforms (the project in the "Shell" folder in the Code Pack samples):

  ShellContainer pics = (ShellContainer)KnownFolders.Pictures; if (ShellLibrary.IsPlatformSupported) pics = (ShellContainer)KnownFolders.PicturesLibrary; 

This uses the My Pictures folder as a backup on older operating systems. KnownFolders is one of the benefits of the Code Pack that offers you as a developer. You can use Environment.SpecialFolder.MyPictures if you are not going to use the Code Pack at all, but why reinvent the wheel?

0
source

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


All Articles