Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
programming4us
Windows 7

Using the Windows 7 Libraries : USING NON-FILESYSTEM CONTAINERS

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
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
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server