public static void ReadFromDisk(string path, bool structure) { try { // actually read it in.... if (Directory.Exists(path)) { foreach (string file in Directory.GetFiles(path, "*.config")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file); XmlNode node = xmlDoc.SelectSingleNode("//MediaType"); if (node != null) { MediaTypeHelper.Import(node, structure); } } foreach (string folder in Directory.GetDirectories(path)) { ReadFromDisk(folder, structure); } } } catch (Exception ex) { LogHelper.Info <SyncMediaTypes>("Read MediaType Failed {0}", () => ex.ToString()); throw new SystemException(String.Format("Read MediaType failed {0}", ex.ToString())); } }
public static void SaveToDisk(MediaType item) { if (item != null) { try { XmlDocument xmlDoc = helpers.XmlDoc.CreateDoc(); xmlDoc.AppendChild(MediaTypeHelper.ToXml(xmlDoc, item)); // xmlDoc.AddMD5Hash(); helpers.XmlDoc.SaveXmlDoc(item.GetType().ToString(), GetMediaPath(item), "def", xmlDoc); } catch (Exception ex) { LogHelper.Info <SyncMediaTypes>("uSync: Error Saving Media Type {0}, {1}", () => item.Text, () => ex.ToString()); } } }