How to get target path for UserName/My Pictures folder?
How can I get target path for "My Pictures" folder in Window Sev开发者_如何学运维en? In Seven we've two folders: "Pictures" and "My Pictures" (second links on a first). So in my app I display both folder, and want understand that "My Pictures" folder is only shot-cut. What attribute should I use or other way?
The Pictures
in Windows 7 is part of Libraries. Windows API code pack has some useful libraries for managing Windows 7 Libraries.
and My pictures
is part of Special folder which you can get using Environment.SpecialFolder. If you are targeting only Windows 7 then I would recommend you to check out the Windows API code pack which has lots of new features which you can use in your application. Has extensive support for libraries and select folder dialog etc
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 libraries exist. Consider these three lines from the ThumbnailToolbarDemoWinforms (a project in the Shell folder of the Code Pack samples):
ShellContainer pics = (ShellContainer)KnownFolders.Pictures;
if (ShellLibrary.IsPlatformSupported)
pics = (ShellContainer)KnownFolders.PicturesLibrary;
This uses the "My Pictures" folder as a fallback on older operating systems. KnownFolders is one of the goodies Code Pack offers you as a developer. You could use Environment.SpecialFolder.MyPictures if you aren't going to use Code Pack at all, but why reinvent the wheel?
精彩评论