private static SiteAuthenticationCollection OpenAndRead(string fileName) { SiteAuthenticationCollection sites = new SiteAuthenticationCollection(); try { if (!string.IsNullOrEmpty(fileName) && System.IO.File.Exists(fileName)) { // Create the serializer var serializer = new XmlSerializer(typeof(SiteAuthenticationCollection)); // Open config file using (var stream = new System.IO.StreamReader(fileName)) { // De-serialize the XML sites = serializer.Deserialize(stream) as SiteAuthenticationCollection; } } } catch (Exception ex) { throw new Exception("Can't read the configuration, 'Recent Sites' is empty.", ex); } return(sites); }
private static void Write(string fileName, SiteAuthenticationCollection sites) { if (!string.IsNullOrEmpty(fileName)) { // Create the serializer var serializer = new XmlSerializer(typeof(SiteAuthenticationCollection)); // Open config file using (var stream = new System.IO.StreamWriter(fileName)) { // Serialize the XML serializer.Serialize(stream, sites); } } }