Can't Access All Elements of a TreeView

So, I am trying to create a file explorer in my program, but when I try to add the functionality of searching for a directory path I run into issues. I am able to successfully search and load a drive or a directory (i.e. E:\) in the first level of a drive
(i.e. E:\My Documents), but that is as far as I can go within the tree view. I believe that it may have something to do with the fact that the code (Link to Code) I
am using creates dummy items in the TreeView. One idea I had was creating a temp string that is just the first directory of the search, then increasing it if it matched and get the directories within, but that didn't work cause I was editing the list of the
foreach I used to traverse the tree. I am at my wits end with trying to figure out a work around and would appreciate all the help I can get.
Link to the full code of the project: Link to Full Project
 The function I am working starts at line 576.
Thanks,
Jesse

You are only adding the folders of the root directory to CompleteList. That's your main issue here.
There is a Directory.Exists method that you can use to determine whether the directory exists. Try the following code for the KeyDown event handler in FileExplorer.xaml.cs:
private void current_dir_KeyDown(object sender, KeyEventArgs e)
if (e.Key.Equals(Key.Enter))
bool found = false;
string search = current_dir.Text;
int slashes = 0;
for (int i = 0; i < search.Length; i++)
if (search[i] == '\\')
slashes++;
string drive = "";
for (int i = 0; i < 3; i++)
drive += search[i];
var current = (DirectoryInfo)null;
if (Directory.Exists(search)) {
DirectoryInfo directory = new DirectoryInfo(search);
var isHidden = (directory.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
var isSystem = (directory.Attributes & FileAttributes.System) == FileAttributes.System;
if (!isHidden && !isSystem) {
found = true;
CompleteList.Add(this.GetItem(directory));
current = directory;
foreach (TreeViewItem item in CompleteList)
if (item.Tag is DirectoryInfo)
current = (DirectoryInfo)item.Tag;
if (search == current.FullName)
expanded_directory.Items.Clear();
ExploreDirectories2(item);
ExploreFiles2(item);
historyBack.Push(currentDisplayItem);
currentDisplayItem = item;
found = true;
return;
if (found != true)
Brush unfound = new SolidColorBrush(Colors.Red);
current_dir.BorderBrush = unfound;
else
return;
It seems to work.
Hope that helps.
Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question. Please don't ask several questions in the same thread.

Similar Messages

  • Not all of my emails show up in my iphone account.  Only about two weeks worth - how can I access all of my inbox emails?

    Not all of my emails show up in my iphone account.  Only about two weeks worth - how can I access all of my inbox emails?  I have hotmail and am not sure if this is a sync glitch or what...?

    How are you accessing the "7 days" account: IMAP or POP?
    Are there other computers accessing the same account?

  • How can i access all the objects of one schema from another schema

    Dear All,
    How can i access all the objects(Tables,Views,Triggers,Procedures,Functions,Packages etc..) and do the modifications of one schema from another schema (Without using synonyms concept).
    Thanks in advance,
    Mahi

    First of all, synonyms only help you easy reference the object. It doesn't have any implication of object privilege.
    As long as you have proper privilege on target object. You can access it with or without synonyms.
    Assuming you have proper privilege of objects, you can use following command to assume schema owner.
    ALTER SESSION SET CURRENT_SCHEMA = Schema_owner

  • I have transferred my itunes library to an external drive. I then attached the external disk to a new computer. I can now access all songs from the new computer. But I can't access playlists. I can still  access all songs and playlists on the old computer

    I have transferred my itunes library to an external drive. I then attached the external disk to a new computer. I can now access all songs from the new computer. But I can't access playlists. I can still  access all songs and playlists on the old computer

    If you right mouse and select Get info it will show you the Apple ID used to purchase these songs.
    Usually the name of an apple id is based on the email. So knowing that you may have forgotten the Apple ID password.
    You can request a new password here http://www.apple.com/support/appleid/

  • Recently, my laptop has been taken and therefore i can not access all the music that was on my old computor, although the music is still on my Ipod, how do i retrieve the music and put it on my new laptop???

    My laptop has been taken and becuase all the music bought from itunes is loaded on to the computor, not the account, i can't access all the music I've previously bought, on my new laptop. I still have my Ipod though and the music is stil on that, how do i transfer the music to my account on my new laptop ??? , xxx

    check out this post by Zevoneer.

  • I recently updated my iPad now I can't access all the documents in the pages app, any advice to to get them back on my iPad?

    I recently updated my iPad now I can't access all the documents in the pages app, any advice to to get them back on my iPad?

    I don't think you're on iOS 5, I think you're using iOS 6.  That's the latest version.
    Unless you've used iCloud to back up your documents, you won't be able to restore them.  And for future reference, you don't have to uninstall Pages to update your iPad anymore.  Sorry about this.

  • I recently got an apple computer at work and downloaded my Juno email on it. Now, I can not access all my past email in my juno inbox from other computers. Pls help.

    I recently got an apple computer at work and downloaded my Juno email on it. Now, I can not access all my past email in my juno inbox from other computers. Pls help.

    If it's a POP account and you set it up in Mail with the option to delete read messages from the server, then you can indeed no longer read it on the server. You may be able to restore the messages to the server if you also have IMAP access. Ask your mail service provider whether it's possible.

  • How can I access all my music when NOT connected to internet? I feet a few of the new ones I purchased but every other song is in grey mode. Meaning they won't play

    How can I access all my music when NOT connected to the internet? I find that the playlists are all grey and the newest bought are the only black ones there fore the only ones playable. How can I access them all with only battery power?

    Nevermind...I did what it said to do in the article and it worked!

  • If I download mavericks on a partition, can i access all my apps

    If I download Mavericks on a partition, can I access all my apps?

    Applications which required an installer may not function. Applications that were installed by drag-copying and contain Intel code generally will.
    (91824)

  • Can I access all of my music and videos on all my devices?

    Can I access all of my itunes music and videos on my Macbook Air and my iPhone?

    All purchased music is available through the cloud. Videos are not currently.
    http://www.apple.com/icloud/features/

  • Can you access all of your HD?

    Can you access all of your Hard Drive when you got 2 partitions of mac and windows 7?
    I was wondering if i could access some files from the mac side of the partition, for instance big files that are used in some programs, because the window partition might be small (40 GB)
    I heard you can access every part of the hard drive when boot in mac, but can it be the other way around? i'm not saying to install applications or anything, its just files, for instance doc, or installation files on the mac partition

    I agree with The hatter.  I like the Paragon HFS drivers for WIndows, and their NTFS Drivers for MacOS.  The native drivers in Snow Leopard or Lion give you read only access to NTFS volumes, and the Boot Camp drivers from Apple give our Windows install Read Only access to HFS+ partitions.  If you want to be able to access the whole drive from either OS, then I think the Paragon drivers are the answer.
    I have a 500GB drive in my MacBook Pro, partitioned 320GB for Lion, and about 175GB for Win7.  I keep my Thnderbird email profle stored on my MacOS partition, and no matter which OS I boot I can have full access to my local mail archives.

  • Can't access 'All My Files' in Finder

    I'm not able to access 'All My Files' in Finder. The below screenshot error appears when selecting Go > All My Files.
    On closer inspection, it appears the entire folder is empty, yet I can manually access files through Spotlight.
    Any suggestions on what my cause this issue would be greatly appreciated.

    It sounds like the "All My Files" Search Folder is damaged or missing.
    Try going to Finder Preferences, Sidebar, and uncheck, then recheck All My Files.
    Not sure that is going to work, but it would be the simplest solution.

  • ICal Leopard: can't access all fields in edit dialog via keyboard

    Hi there
    Any clues on using the keyboard to access all the fields in the event edit dialog?
    In iCal Tiger, you could tab between all fields - in Leopard tabbing seems to bypass some fields (the all day checkbox for instance).
    Annoying.

    I don't have a solution, but whoever decided to make these changes to iCal must not use iCal that much because it's driving me up the walls. I have to go through and look at many ical appointments and compare them, make notes, etc... and now I can't just see the information, I have to double-click on EVERY item just to see the information? Where is the logic in this? I want my drawer back!

  • Can't access Photoshop Elements 10

    I purchased photoshop elements 10 from a dealer and loaded it, now I can't access it.

    hi Jim,
    Are you getting any error message?Screenshot of the error message would be great if any.
    Also please confirm the system infomation.
    Looking forward to your reply.
    Regards,
    Sumit Singh

  • Can not access all websites

    In the last 3 weeks I have not been able to access all websites. There were no changes to the computer when this occured. The computer is only used to go online to pay bills and check email. I can access cbsnews.com but not nbcnews.com. I also cannot access the microsoft web sites among others. I reset the computer to factory settins but the problem still exists. My other computers using the wireless router work fine. This desktop is wired directly to the router. This happens with IE and Mozilla. I use Avast free antivirus and have boot scanned the computer.   Thanks for the help.

    I think I may have solved the problem although I haven't used this computer much since I did what I did. I was using Avast free antivirus and have uninstalled it and installed another antivirus. This, so far, has seemed to work.

Maybe you are looking for

  • How can i erase only the music i don't like from my ipod ?

    how can i erase only the music i don't like from my ipod ?

  • AR Invoice in Crystal Report

    Experts, I am new to SAP. I want to create a AR invoice in Crystal report...where field will be like Header Level 1. Name and Address Of Consignee 2. Party's Order No 3. Tax Invoice No 4. Order Date 5. Tax Invoice Date 6. Buyer's VAT TIN/CST TIN No.

  • My bejeweled game is frozen and I can't get it unstuck

    My game bejeweled is frozen and I can't get it unstuck.  Help.

  • Mac Pro Apple TV connection...

    Why doesnt my Mac Pro have the apple TV icon activated on the top of screen? I am unable to mirror my Mac Pro through my Apple TV.. Friends were over the other day and suggested I update the operating system.. So I have update to OS Mountain Lion 10.

  • Unwanted Work Items in inbox

    Dear all, i AM GETTING AN UNWANTED WORK ITEEM IN THE BUSINESS WORK PLACE IN THE CASE OF INBOUND PROCESSING OF IDOC Orders. eVEN THOUGHT THE ORDER IS POSTED PERFECTLY. IDoc 0000000001529080: status 53 cannot be processed Thanks in advance