Logo
HOW TO
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows 7

Using the Windows 7 Libraries : USING NON-FILESYSTEM CONTAINERS

7/30/2014 8:58:08 PM

As previously mentioned, non-filesystem containers are simply entries that aren't part of the filesystem. Because these entries aren't part of the filesystem, the IKnownFolder.GetKnownFolder() method actually creates these entries using the NonFileSystemKnownFolder type. You won't actually use the NonFileSystemKnownFolder type, though, or work with the IKnownFolder.GetKnownFolder() method. The KnownFolders class presents these objects using the ShellNonFileSystemItem type, which is how you detect them. The Non-Filesystem example demonstrates how to work with this entry type.

1. Configuring the Non-Filesystem Example

This example begins with a Windows Forms application. You'll need to add a List button (btnList) to obtain a list of the non-filesystem containers and their content, and a list box (lstOutput) to output the results of the query. In order to see the content this example has to provide, you'll want to make the dialog box bigger than normal to accommodate the extra text (set the form's Size.Width property to 600 and the Size.Height property to 750 if possible). In addition, you'll need to add a reference to Microsoft.WindowsAPICodePack.Shell.DLL and provide the following using statement:

using Microsoft.WindowsAPICodePack.Shell;

2. Writing the Non-Filesystem Example Code

A number of non-filesystem containers are provided with the KnownFolders class. For example, the KnownFolders.Connections property is a non-filesystem container. The example relies on another non-filesystem container, KnownFolders.Games. This isn't the actual Games folder on your system, but rather a description of the games on your system, such as their Entertainment Software Rating Board (ESRB) rating. The site at http://www.esrb.org/ tells you more about these ratings. Listing 1 shows the code needed for this example.

Example 1. Displaying non-filesystem container information
private void btnList_Click(object sender, EventArgs e)
{
// Clear the previous entries.
lstOutput.Items.Clear();

// Process each of the entries.
foreach (var Entry in KnownFolders.Games)
{
// Verify that the entry is the correct type.
if (Entry.GetType() == typeof(ShellNonFileSystemItem))
{
// Coerce the entry type.
ShellNonFileSystemItem Item = (ShellNonFileSystemItem)Entry;

// Output information about the entry.
lstOutput.Items.Add("Name: " + Item.Name);
lstOutput.Items.Add("Parsing Name: " + Item.ParsingName);
lstOutput.Items.Add("Is File System Object? " +
Item.IsFileSystemObject);
lstOutput.Items.Add("Is Link? " + Item.IsLink);

// Process the default properties for the item.
lstOutput.Items.Add("Default Properties:");
foreach (var Property in
Item.Properties.DefaultPropertyCollection)

// List the property name and value.
lstOutput.Items.Add("\t" + Property.CanonicalName +


": " + Property.ValueAsObject);

// Process some of the system properties for the item.
lstOutput.Items.Add("System Properties:");
lstOutput.Items.Add("\tApplication Name: " +
Item.Properties.System.ApplicationName.Value);
lstOutput.Items.Add("\tAuthor: " +
Item.Properties.System.Author.Value);
lstOutput.Items.Add("\tCompany: " +
Item.Properties.System.Company.Value);
lstOutput.Items.Add("\tCopyright: " +
Item.Properties.System.Copyright.Value);

// Add a blank line for each item.
lstOutput.Items.Add("");
}
}
}

The example begins by accessing the entries in the KnownFolders.Games property using a foreach loop. In this case, you know that the entries are going to be type ShellNonFileSystemItem, but it pays to verify that they're the correct type to avoid errors later in the code.

As with known folders, a non-filesystem container has properties like Name, ParsingName, and IsFileSystemObject. The Path property also exists, but is usually blank because a non-filesystem container doesn't have a place on the filesystem (local hard drive or network).

When working with a non-filesystem container, the Properties property takes on added significance. You want to check Properties.DefaultPropertyCollection for entries that define the non-filesystem container. The example simply enumerates through all the properties so you can see what's available. The properties will vary by the kind of non-filesystem container.

Figure 1. Non-filesystem containers work with data outside the filesystem.

The Properties property also contains System. Unlike Properties.DefaultPropertyCollection, you can't enumerate Properties.System. Consequently, you must individually query values such as Properties.System.ApplicationName.Value. Unfortunately, Properties.System seldom contains any actual values, so you'll want to use Properties.DefaultPropertyCollection instead. Figure 1 shows typical output from this example.

Other -----------------
- Using the Windows 7 Libraries : WORKING WITH KNOWN FOLDERS
- Conducting Research in OneNote 2010 : Translating Text
- Conducting Research in OneNote 2010 : Researching a Topic, Customizing the Research Task Pane
- Conducting Research in OneNote 2010 : Handling the Research Task Pane
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Setting Macro Security Options
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Setting ActiveX Security Options
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Setting Add-in Security Options
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Setting Document Related Security Options
- Microsoft Excel 2010 : Protecting and Securing a Workbook - Selecting Trusted Publishers and Locations
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 3) - Translating Text with the Mini Translator
 
 
REVIEW
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
 
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
Top 10
- Microsoft Excel : How to Use the VLookUp Function
- Fix and Tweak Graphics and Video (part 3) : How to Fix : My Screen Is Sluggish - Adjust Hardware Acceleration
- Fix and Tweak Graphics and Video (part 2) : How to Fix : Text on My Screen Is Too Small
- Fix and Tweak Graphics and Video (part 1) : How to Fix : Adjust the Resolution
- Windows Phone 8 Apps : Camera (part 4) - Adjusting Video Settings, Using the Video Light
- Windows Phone 8 Apps : Camera (part 3) - Using the Front Camera, Activating Video Mode
- Windows Phone 8 Apps : Camera (part 2) - Controlling the Camera’s Flash, Changing the Camera’s Behavior with Lenses
- Windows Phone 8 Apps : Camera (part 1) - Adjusting Photo Settings
- MDT's Client Wizard : Package Properties
- MDT's Client Wizard : Driver Properties
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro