PDA

Click to See Complete Forum and Search --> : this sucks! I need some serious help!!!


Buy2easy.com
Jul 26th, 2002, 08:56 AM
I am writing an auction program but i have come to a screecking halt. I have a treeview list were i can ad nodes and child nodes i want to be able to save the collection of nodes to a file so that it can be opened and edited my my program users so they can keep stuff in order. but i can not save it as a treenodecollection because if throws a I/O error when it tries to save a treenodecollection object what can i do to fix this problem!!! Please Help!!! And thanks for any help you give!

also my user name use to be "B2E" but it does not work anymore and half the time i try to come to this site it does not work!

Buy2easy.com
Jul 26th, 2002, 09:30 AM
Bump

Edneeis
Jul 26th, 2002, 10:18 AM
I'm sure there is a better way with all the serialization tricks in .net but you can always do it old school and loop through the nodes and write them to whatever you want.

Matt02
Jul 26th, 2002, 03:06 PM
Here's my 2 cents on the matter. The TreenodeCollection class is not serializable, but however the System.ArrayList class is, so rather than having to loop through and save each property individually, you could just loop through and convert each node to a member of an arraylist and serialize that. There are still big problems with this, since you will need to work out a way of mapping the treenodes that will be preserved in the array, but its a start.

hellswraith
Jul 26th, 2002, 03:18 PM
A quick question...
when you guys are talking about making something serializable, do you mean put it into a long string?

I see a lot of that word being thrown around, and applied to everything lately, but don't understand what is being ment by it.

Matt02
Jul 26th, 2002, 03:44 PM
Here is a quick example...

Dim filestream As New System.IO.FileStream("C:\temp.dat", IO.FileMode.Create)

Dim formatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()

Dim temp(34) as integer

Okay, so now you have a filestream that points to the file you want to save the serialized info to, your serialization formatter and your data to be serialized. Now you just use the command

formatter.Serialize(filestream, temp)

And there you have it, "temp.dat" now contains all the data from the integer array in a binary format which can be read in much the same fashion with

temp = stuff2.Deserialize(filestream)

(provided the filestream is set to read instead of write). So for a brief explanation of serialization; its just a way of encoding classes for them to be saved or transmitted (with .net remoting).
For a class to be able to be serialized it needs to have a <Serializable> tag at the front of it when you look it up in the help file. (if you want to make your own serializable class then you will need to read about what rules apply to it). and finally the only other thing I know about serialization is that instead of using the binary formatter you can also use a soap formatter. Anyway, I'm not an expert at serialization so you should probably look it up if you want to actually use it properly, but at least now you should have some idea of what it is.

Buy2easy.com
Jul 28th, 2002, 02:05 PM
I need to be able to get the tag from the node because i put useful(needed info in it if i put it into an array then can it be saved and work like that and me be able to retrieve the tag when i bring it back from the file.


What i really need is a code example if you would be willing to post one of how i could turn it into an array save it and then i can bring it back from the file if i can see how to save it Thanks a lot you guys have been a big help!

Buy2easy.com
Jul 29th, 2002, 05:02 PM
how would i loop through the treeview1 and pull out each node(including nodes which are sub nodes) and place them into a array list. I tried doing it by the index of each node, but sub nodes are classified as the same index as their parent nodes how can i get arround this and place each node into an array list

p.s. some example code would be GREAT!!

Thanks!

Buy2easy.com
Jul 29th, 2002, 05:09 PM
how would i loop through the treeview1 and pull out each node(including nodes which are sub nodes) and place them into a array list. I tried doing it by the index of each node, but sub nodes are classified as the same index as their parent nodes how can i get arround this and place each node into an array list

p.s. some example code would be GREAT!!

Thanks!

Buy2easy.com
Jul 29th, 2002, 11:27 PM
how do you serialise an arraylist and how do you deserialize it back into an array list i have tried and tried and failed each time

BlahDoS
Jul 30th, 2002, 09:42 AM
use XML

Buy2easy.com
Jul 30th, 2002, 10:18 AM
xml? how whould i do that? could you explain it to me?