private TreeViewItem AddLibraries()
 {
     StackPanel panel = new StackPanel();
     IKnownFolder iKnownFolder = KnownFolders.UsersLibraries;
     ShellObject shellObject = ShellFolder.FromParsingName(iKnownFolder.ParsingName);
     panel.Orientation = Orientation.Horizontal;
     Image image = new Image();
     image.Source = shellObject.Thumbnail.SmallBitmapSource;
     image.Width = image.Height = 16;
     panel.Children.Add(image);
     TagInfo info = new TagInfo(shellObject.Name, iKnownFolder.Path);
     TextBlock textBlock = new TextBlock();
     textBlock.Text = info.Name;
     panel.Children.Add(textBlock);
     TreeViewItem item = new TreeViewItem();
     item.Header = panel;
     item.Tag = info;
     dirView.Items.Add(item);
     item.IsExpanded = true;
     //item.Items.Add(CreatTreeViewItem(new TagInfo("Documents", Environment.GetFolderPath(Environment.SpecialFolder.Personal))));
     //item.Items.Add(CreatTreeViewItem(new TagInfo("Music", Environment.GetFolderPath(Environment.SpecialFolder.MyMusic))));
     //item.Items.Add(CreatTreeViewItem(new TagInfo("Pictures", Environment.GetFolderPath(Environment.SpecialFolder.MyPictures))));
     //item.Items.Add(CreatTreeViewItem(new TagInfo("Videos", Environment.GetFolderPath(Environment.SpecialFolder.MyVideos))));
     //item.Items.Add(CreatTreeViewItem(new TagInfo("Downloads", "")));
     foreach (var shellObj in iKnownFolder)
     {
         try
         {
             ShellLibrary shellLibrary = ShellLibrary.Load(shellObj.Name, true);
             if (shellLibrary.Count > 0 && Directory.Exists(shellLibrary.DefaultSaveFolder))
                 item.Items.Add(CreatTreeViewItem(new TagInfo(shellObj.Name, shellLibrary.DefaultSaveFolder)));
         }
         catch
         {
         }
     }
     return item;
 }
 private TreeViewItem CreatTreeViewItem(TagInfo info)
 {
     StackPanel panel = new StackPanel();
     panel.Orientation = Orientation.Horizontal;
     Image image = new Image();
     image.Source = list.GetDirectoryImage(info.Path, true);
     image.Height = image.Width = 16;
     panel.Children.Add(image);
     TextBlock textBlock = new TextBlock();
     textBlock.Text = info.Name;
     panel.Children.Add(textBlock);
     TreeViewItem item = new TreeViewItem();
     item.Header = panel;
     item.Tag = info;
     item.ToolTip = info.Name;
     TreeViewItem tmpitem = new TreeViewItem();
     tmpitem.Header = "@@";
     item.Expanded += new RoutedEventHandler(item_Expanded);
     if (null != this.dirTreeViewContextMenu)
     {
         item.ContextMenu = this.dirTreeViewContextMenu;//;;'
     }
     item.Items.Add(tmpitem);
     return item;
 }
        private TreeViewItem AddComputer( )
        {
            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            IKnownFolder iKnownFolder = KnownFolders.Computer;
            ShellObject shellObject = ShellFolder.FromParsingName(iKnownFolder.ParsingName);
            Image image = new Image();
            image.Source = shellObject.Thumbnail.SmallBitmapSource;
            image.Width = Height = 16;
            panel.Children.Add(image);
            TagInfo info = new TagInfo(shellObject.Name, iKnownFolder.Path);

            TextBlock textBlock = new TextBlock();
            textBlock.Text = info.Name;
            panel.Children.Add(textBlock);
            TreeViewItem item = new TreeViewItem();
            item.Header = panel;
            item.Tag = info;
            item.IsSelected = true;
            dirView.Items.Add(item);
            item.IsExpanded = true;

            foreach (var obj in iKnownFolder)
            {
                if(Directory.Exists(obj.ParsingName))
                {
                    item.Items.Add(CreatTreeViewItem(new TagInfo(obj.Name, obj.ParsingName)));
                }
            }
            //System.IO.DriveInfo[] disk = System.IO.DriveInfo.GetDrives();
            //foreach (System.IO.DriveInfo di in disk)
            //{
            //    if (di.DriveType != DriveType.CDRom && di.DriveType != DriveType.Network)
            //    {
            //        string name = "(" + di.Name.Substring(0, 2) + ")";
            //        string lable = (di.VolumeLabel == "") ? "Local Disk" : di.VolumeLabel;
            //        item.Items.Add(CreatTreeViewItem(new TagInfo(lable + name, di.RootDirectory.FullName)));
            //    }
            //}

            return item;
        }