B
_BNC
I've got an ArrayList of objects that I'd like to save/retrieve as quickly
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.
I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?
The function itself is listed below, but I think it's boilerplate:
private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.
I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?
The function itself is listed below, but I think it's boilerplate:
private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}