Monday, March 15, 2010

Windows 7 Libraries C# Quick Reference

Following are some listings to be used as a quick reference to common Windows 7 Libraries features using Windows API Code Pack.

The code in this post is based on previous work by Alon and other Sela team members. Great work all.

Forward

Just to clarify the terminology used: Every Windows 7 library is represented as an XML file with the .library-ms extension. The common libraries files are commonly stored in: C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Libraries\

So if, for example, we work now with the Pictures library, than in the following sections:

libraryName = Pictures
locationPath = C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Libraries\

Note: you can create library files wherever you want, not necessarily in the mentioned folder.

Features

Creating a new library
-------------------------------
ShellLibrary shellLibrary = new ShellLibrary(libraryName, locationPath, overwriteExisting);

Add folder to an existing library
--------------------------------------------
using (ShellLibrary shellLibrary = ShellLibrary.Load(libraryName, folderPath, isReadOnly))
{
   shellLibrary.Add(folderToAdd);
}

Read more: Arik Poznanski's Blog

Posted via email from jasper22's posterous