open a file into treeview
hy
i have a problem with a treeview
i have a file named file:
now i want it to open the file and: when website (likewww.google.com) add the website (this is working), but i also want it to make a new root and add al later websites to that root when there is a + in the file.
Also when there i a - it must go to the top level.
i now have this code but it gave me no results
private
void openFavorites(){
try{
FileStream list =newFileStream("favorites.txt",FileMode.Open);StreamReader reader =newStreamReader(list);while (reader.EndOfStream ==false){
string line = reader.ReadLine();if (line =="+"){
TreeNode root1 =newTreeNode();line = reader.ReadLine();
root1.Nodes.Add(line);
}
else{
treeView1.Nodes.Add(line);
}
}
if (reader.EndOfStream ==true){
reader.Close();
list.Close();
}
}
catch{
MessageBox.Show("error with file");Application.Exit();}
can anybody help me with this?
thanks in advance
[2726 byte] By [
ozakiweb] at [2007-12-25]
hey that helped!
but its very bugious (its not your code but anyway)
its my first c# program and can someone take a look at it
it does strange things like copy the treeview 5 times (when i click a link or click the go button)
i zipped it and its 3.677 mb
link: 
(yes i see its 3.59 LOL)
thanks in advance!
greets
Hi
First thing what I find is place where you call 'openFaivorites' function.
Form's Activated event is't write place to call this kind of method.
At least you must clear treeview every time, but anyway it's better if you call it on form's Load event.
So I recomment that you move openFaivorites() function call from Browser_Activeted event to Browser_Load event and
add treeView clear comman to openFaivorites function.
private void openFavorites()
{
treeView1.Nodes.Clear();
....
Yours Markku
Hi
Second thing is those 'this.update()' calls.
There isn't any reason for them.
Actually update() causes that flash effect.
And that form's Activated event handler is wrong place take 1 second brake.
I understand why it is there but mayby you should do it only ones. I mean something like this:
private
bool splash = true;private void Browser_Activated(object sender, EventArgs e)
{
if (splash)
{
splash = false;
Thread.Sleep(1000);
splashscreen.Close();
}
}
Yours
Markku
okay thanks!
it now does not copy the treeview.
and when i minimize and the maximze it doesnt delay!
but i have stil one problem:
i need it to only when i click a link in the favorites with www. in the string it must go tho that webpage
i tryed:
private void treeView1_MouseDoubleClick_1(object sender, MouseEventArgs e) { try { node = treeView1.SelectedNode.Text; comp = "www.";if (string.Equals(comp, node, StringComparison.Ordinal) != true){ node = "not";} } catch{ } if (node != "not"){ this.NavigateToUrl(node);} else{ } |
|
its also in the download
thanks in advance