Quantcast
Viewing all articles
Browse latest Browse all 12583

Treeview (checking duplicates) - why does my If statement not work correctly?

I'm populating treeview nodes like this:

  • text=filename
  • tag=fullpath including filename

So, when I want to add another item/node, I check to see if it's already there (bool IsThere):

foreach (TreeNode tn in tvRecent.Nodes)
{
    if ((tn.Text == filename)  && (tn.Tag== filePath))
    { isThere = true; }
}

if (isThere == false)
{.....add it to the treeview}

I have watches configured for tn.Text, filename, tn.Tag and filePath. When trying to add a file I know is a duplicate, tn.Text does indeed equal filename AND tn.Tag Does indeed equal filePath. Therefore, in my estimation, isThere should be evaluated, equaling 'true'.....

However, isThere never gets addressed as true....in debug mode, it passes the 'isThere = true;' line altogether. So, it just gets assigned 'false' as a value

BTW - if I separate them out, filename does get evaluated equally, but filePath doesn't. The format for filePath is:

D:\\websites\\MyPath\\\contact.aspx

Any ideas?




Viewing all articles
Browse latest Browse all 12583

Trending Articles