svemir
asked on
FileStream and BinaryFormatter
Hello!
I use FileStream to save my project (Calculation) to hard drive. It works fine. Problem is when I change something in Calculation class that it can not read it again because of different number of items in it. What could I do to make old versions readable?
BinFormatter.Serialize(FSt ream, actCalcForm.actCalculation )
Thanks!
I use FileStream to save my project (Calculation) to hard drive. It works fine. Problem is when I change something in Calculation class that it can not read it again because of different number of items in it. What could I do to make old versions readable?
BinFormatter.Serialize(FSt
Thanks!
ASKER
Well,
actually it can be stored where ever user want to. One way to solve this problem is to keep old classes a live inside of application and call it when needed. In that case I need to write additional source code to rewrite informations to new class. Usually it is not a problem because most of inherited classes in main class which I serialize are same. Anyway it seams to me less complicated than old fasion storing data.
I hope that you have better idea about my question.
Thank you anyway.
actually it can be stored where ever user want to. One way to solve this problem is to keep old classes a live inside of application and call it when needed. In that case I need to write additional source code to rewrite informations to new class. Usually it is not a problem because most of inherited classes in main class which I serialize are same. Anyway it seams to me less complicated than old fasion storing data.
I hope that you have better idea about my question.
Thank you anyway.
I'm sorry (as I had anything to do with it! :)) but you just can't.
Binary serialization doen't support different versions, only XML.
If you have a choice, serialize the Calculation class to XML instead of binaly.
The problem can be the security, XML is pretty much human readable.
To overcome this you can:
1- If you really need a very good protection, ecrypt the XML file, using DES or TDES implementes on the System.Security.Cryptograp hy namespace.
2- If you just want put some camuflage on the file just don't save the file as *.xml, choose another file extension :)
Alex :p
Binary serialization doen't support different versions, only XML.
If you have a choice, serialize the Calculation class to XML instead of binaly.
The problem can be the security, XML is pretty much human readable.
To overcome this you can:
1- If you really need a very good protection, ecrypt the XML file, using DES or TDES implementes on the System.Security.Cryptograp
2- If you just want put some camuflage on the file just don't save the file as *.xml, choose another file extension :)
Alex :p
ASKER
Could you please give some example of serialization to XML because once I try and it doesn't work.
Thanks!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bob