Serialization to and from XML document file using XmlSerializer object

Description and code samples
Table of Contents
Operations
Serialize/De-serialize to/from XML file/object using XmlWriter/XmlTextWriter and FileStream
How to do it
// BUILD COLLECTION 

List<Book> lvLibrary = new List<Book>();

Book lvBook = new Book();
lvBook.Author = "João Seixas";
lvBook.Title = "Training serialization book";
lvLibrary.Add(lvBook);

lvBook = new Book();
lvBook.Author = "João Seixas";
lvBook.Title = "Training serialization book (Second edition)";
lvLibrary.Add(lvBook);

// SERIALIZE OBJECT (encoding UTF-8)

XmlSerializer serializer = new XmlSerializer(typeof(List<Book>), new XmlRootAttribute("Library"));

XmlWriterSettings wSettings = new XmlWriterSettings();
wSettings.Indent = true;
wSettings.Encoding = Encoding.UTF8;
wSettings.OmitXmlDeclaration = false;

using (FileStream fs = new FileStream(@"c:\tmp\file.xml", FileMode.CreateNew))
{
	using (XmlWriter xWriter = XmlWriter.Create(fs, wSettings))
    {
		serializer.Serialize(xWriter, lvLibrary);
	}

}

// DE-SERIALIZING XML

XmlReaderSettings rSettings = new XmlReaderSettings();

using (FileStream fs = new FileStream(@"c:\tmp\file.xml",FileMode.Open))
{
	using (XmlReader xReader = XmlReader.Create(fs, rSettings))
    {
		lvLibrary = (List<Book>)serializer.Deserialize(xReader);
	}
}
<?xml version="1.0" encoding="utf-8"?>
<Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Book>
    <Author>João Seixas</Author>
    <Title>Training serialization book</Title>
  </Book>
  <Book>
    <Author>João Seixas</Author>
    <Title>Training serialization book (Second edition)</Title>
  </Book>
</Library>