Thank you, for some more detail, I need to make a table which a user can look through with the file names and paths and the program to writeXML from that table.
The quantity of paths really depend on the user. But it's not going to be like a thousand but I am guessing maybe ten to fifty. I just need a list or a table that can hold and scroll about fifty.
Some other thing is that it would be nice if I could add a size of the file onto the table also.
I think you may find a datatable convenient, like someone mentioned. I'm unsure if the path object is serializable, if it is not then this will not be an option for you.
Consider the following:
using System.Data; DataTable pathLookupTable = new DataTable(); pathTable.Columns.Add("PathName", typeof(string)); pathTable.Columns.Add("PathObject", typeof(Path));
This gives you a generic datatable object that is capable of storing path objects by name. The problem with the datatable is performance is not spectacular (the surrounding boilerplate to simply get a column value out of a table reference is something like 4+ levels deep) You could also do the same with a generic list, consider the following:
using System.Collections.Generic; Dictionary<string, Path> pathLookupTable = new Dictionary<string, Path>();
Using the Dictionary<> object would be easier to work with in code, it supports serialization, but becuase there is no convenient serialization/persistence methods you would need to write that code yourself, this can be done by using the BinaryFormatter.Serialize and BinaryFormatter.Deserialize methods (they are easy to use, requiring you to only pass in a stream and object to be serialized, or for deserialization just the stream to deserialize from), for this consider the following:
BinaryFormatter myFormatter = new BinaryFormatter(); FileStream myStream = File.Create(@"C:\PathStorageTest.dat"); // TODO you will want to delete the file if it already exists. myFormatter.Serialize(myStream, pathLookupTable); myStream.Close(); myStream = File.Open(@"C:\PathStorageTest.dat"); pathLookupTable = (Dictionary<string, Path>)myFormatter.Deserialize(myStream); myStream.Close();
That's about all there is to serialization/deserialization from a consumer perspective. Pretty simple stuff. At work I use Dictionary<> to store thousands of objects so it should handle your load just fine.
If you have no need to store multiple paths by name you can use a List<Path> instead of a Dictionary<>.
If you don't have .NET 2.0 you can use a Path[] (path object array) instead, the serialization/deserialization will be the same.
If you're only looking to store a SINGLE path object then just modify the serialization code to accept/return a path object instead of a collection/array.
All of these options are dependant on the target object(s) being serializable, if any object in the tree is not serializable the framework will let you know. If that's the case then you will need to either create a structure that can be serialized or write the data to a stream yourself.
Thank you very much of your response! But I have no clue of what you are talking about. It would be great if you can send like a sample source file and just give me a sample along so I can have some clue.
Thank You! Keehun Nam
P.S. If you want to email some source files, please email to knvb1123@gmail.com
So a DataSet and creating your own Datatable will probably do the trick as you can read and write the XML in and it binds to nearly all the data controls in .NET.
It really depends on what you want to do with the list. There are a number of formats and mediums for storage, each with advantages and disadvantages. It also depends on things like how many paths you need to store Will you be searching though them or using them to drive a user interface Do you need to store additional information with the path such as the number of files at that location, or the size of the specific file the path refers to
People will be able to provide a more meaningful answer if you can give a little more detail.
Not sure exactly what you are asking for but something like the following I hope .
A table schema of
FileId int FilenameAddress string
You could use this as a dataset and save the information using WriteXml and ReadXml or you could use proper datatable in sqlserver with the same type of schema.
What is appropriate for this?
frans poc
Thank you,
for some more detail,
I need to make a table which
a user can look through with the file names and paths and
the program to writeXML from that table.
The quantity of paths really depend on the user.
But it's not going to be like a thousand but
I am guessing maybe ten to fifty. I just need a list or
a table that can hold and scroll about fifty.
Some other thing is that it would be nice if
I could add a size of the file onto the table also.
Thank you for your help!
Keehun Nam
thanh dao
Consider the following:
using System.Data;
DataTable pathLookupTable = new DataTable();
pathTable.Columns.Add("PathName", typeof(string));
pathTable.Columns.Add("PathObject", typeof(Path));
This gives you a generic datatable object that is capable of storing path objects by name. The problem with the datatable is performance is not spectacular (the surrounding boilerplate to simply get a column value out of a table reference is something like 4+ levels deep) You could also do the same with a generic list, consider the following:
using System.Collections.Generic;
Dictionary<string, Path> pathLookupTable = new Dictionary<string, Path>();
Using the Dictionary<> object would be easier to work with in code, it supports serialization, but becuase there is no convenient serialization/persistence methods you would need to write that code yourself, this can be done by using the BinaryFormatter.Serialize and BinaryFormatter.Deserialize methods (they are easy to use, requiring you to only pass in a stream and object to be serialized, or for deserialization just the stream to deserialize from), for this consider the following:
BinaryFormatter myFormatter = new BinaryFormatter();
FileStream myStream = File.Create(@"C:\PathStorageTest.dat"); // TODO you will want to delete the file if it already exists.
myFormatter.Serialize(myStream, pathLookupTable);
myStream.Close();
myStream = File.Open(@"C:\PathStorageTest.dat");
pathLookupTable = (Dictionary<string, Path>)myFormatter.Deserialize(myStream);
myStream.Close();
That's about all there is to serialization/deserialization from a consumer perspective. Pretty simple stuff. At work I use Dictionary<> to store thousands of objects so it should handle your load just fine.
If you have no need to store multiple paths by name you can use a List<Path> instead of a Dictionary<>.
If you don't have .NET 2.0 you can use a Path[] (path object array) instead, the serialization/deserialization will be the same.
If you're only looking to store a SINGLE path object then just modify the serialization code to accept/return a path object instead of a collection/array.
All of these options are dependant on the target object(s) being serializable, if any object in the tree is not serializable the framework will let you know. If that's the case then you will need to either create a structure that can be serialized or write the data to a stream yourself.
Hope that helps..
mdooley
But I have no clue of what you are talking about.
It would be great if you can send like a sample source file
and just give me a sample along so I can have some clue.
Thank You!
Keehun Nam
P.S.
If you want to email some source files, please email to
knvb1123@gmail.com
doobey
I said about 10 to 50 paths. I don't think that
there will be more or less.
Thank You for your help!
Keehun Nam
David Bridge
Do you need an example
James
Marvy
People will be able to provide a more meaningful answer if you can give a little more detail.
Thanks!
Red Link
A table schema of
FileId int
FilenameAddress string
You could use this as a dataset and save the information using WriteXml and ReadXml or you could use proper datatable in sqlserver with the same type of schema.
How many paths will there be in the list
Cheers,
James