Click here to Skip to main content
15,887,596 members

Comments by Saeed Jafarian (Top 27 by date)

Saeed Jafarian 12-Aug-15 11:34am View    
ok, thank you for your helps
Saeed Jafarian 12-Aug-15 11:31am View    
i use this article for my codes

http://www.codeproject.com/Articles/422474/Serialization-using-different-formats-in-NET

and i need server.mappath because it is a website project
Saeed Jafarian 12-Aug-15 11:26am View    
no i get just one file for course list<>.
the point is i am deserializing the xml to the list without problem, even with the database and encoding i could deserialize. but the reference is broken between object.
Saeed Jafarian 12-Aug-15 11:07am View    
ok now i do it with fileStream
serializing:

DataContractSerializer CourseSerializer = new DataContractSerializer(typeof(List<'course'>), null, int.MaxValue, false, true /* preserveObjectReferences */, null);
XmlDictionaryWriter writer = null;
FileStream fs = null;
fs = new FileStream(Server.MapPath("course.xml"), FileMode.Create);
writer = XmlDictionaryWriter.CreateTextWriter(fs);
CourseSerializer.WriteObject(writer, Courses);
writer.Close();
fs.Close();


deserializing:

FileStream fs = null;
DataContractSerializer ser = null;
XmlDictionaryReader reader = null;
fs = new FileStream(Server.MapPath("course.xml"), FileMode.OpenOrCreate);
reader = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
ser = new DataContractSerializer(typeof(List<course>));
Courses = (List<'course'>)ser.ReadObject(reader);
fs.Close();
reader.Close();

and do it for level and prof list either

no database, no encoding, just stream, but the problem not solved....
Saeed Jafarian 12-Aug-15 9:52am View    
here i upload the xml output for a simple run of the application for consideration

http://s000.tinyupload.com/?file_id=01744593121547335786