Hello Marc,
Sounds like it should work (although hard to tell without code).
This isn't as simple as forgetting to rewind a stream, is it?
no it isn't. I use the binary from the serilized stream, if i write directly
to file first, then open it, encrypt and write to another it works really
fine, but that's not the preferred way..... here's some code:
using (MemoryStream stream = X0Serialization.XmlSerializer.Serialize(typeof(Pro bingPaths),
ProbingPaths)) {
FileCryptography.Encrypt(stream, Filename);
}
encrypt is just the function that does the symmetric cryptography I think
code for that is not needed as it only get's the bytes from the MemoryStream
and encrypt them.
Here's the Serialized class, really simple!
[Serializable(), MSSerialization.XmlRoot("Probing")]
public sealed class ProbingPaths {
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private List<stringpaths;
[MSSerialization.XmlElement(ElementName="PrivatePat h")]
public List<stringPaths {
get {
if (this.paths != null) {
return this.paths;
} else {
return Paths = new List<string>();
}
}
set {
paths = value;
}
}
public ProbingPaths() {
}
}
The serialization is done this way:
public static MemoryStream Serialize(Type type, object o) {
MemoryStream stream = new MemoryStream();
try {
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(type);
serializer.Serialize(stream, o);
return stream;
} catch {
throw;
}
}
so i think there are no possibilities to produce silly errors by code, or?
regards
sascha