/// <summary> /// Save settings into the given file. /// </summary> /// <param name="fileName">file to save settings to</param> /// <param name="syncPathList">list with paths to synchronize</param> public void SaveJob(string fileName, SyncPathList syncPathList) { XmlAttribute attr; XmlElement root; XmlNode node; XmlDocument doc = new XmlDocument(); XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); doc.AppendChild(xmlnode); root = doc.CreateElement("InZync"); // save paths to synchronize node = doc.CreateElement("SourcePaths"); foreach (PathPair pp in syncPathList) { XmlNode pathNode = doc.CreateElement("Path"); attr = doc.CreateAttribute("source"); attr.Value = pp.Source; pathNode.Attributes.Append(attr); attr = doc.CreateAttribute("destination"); attr.Value = pp.Destination; pathNode.Attributes.Append(attr); node.AppendChild(pathNode); } root.AppendChild(node); node = doc.CreateElement("ShowLog"); node.InnerText = ShowLogWindow.ToString(); root.AppendChild(node); node = doc.CreateElement("SaveLog"); node.InnerText = SaveLog.ToString(); root.AppendChild(node); node = doc.CreateElement("AppendLog"); node.InnerText = AppendLog.ToString(); root.AppendChild(node); node = doc.CreateElement("LogFile"); node.InnerText = LogFile; root.AppendChild(node); node = doc.CreateElement("ReadOnly"); node.InnerText = RemoveReadOnlyFlag.ToString(); root.AppendChild(node); node = doc.CreateElement("DirectoriesLikeFiles"); node.InnerText = DirectoriesLikeFiles.ToString(); root.AppendChild(node); node = doc.CreateElement("SubDirectories"); node.InnerText = SubDirectories.ToString(); root.AppendChild(node); node = doc.CreateElement("HiddenFiles"); node.InnerText = ProcessHiddenFiles.ToString(); root.AppendChild(node); node = doc.CreateElement("SystemFiles"); node.InnerText = ProcessSystemFiles.ToString(); root.AppendChild(node); node = doc.CreateElement("TerminateApp"); node.InnerText = TerminateApp.ToString(); root.AppendChild(node); node = doc.CreateElement("RunSilent"); node.InnerText = RunSilent.ToString(); root.AppendChild(node); node = doc.CreateElement("Extensions"); node.InnerText = ExtensionList; root.AppendChild(node); node = doc.CreateElement("ExcludedExtensions"); node.InnerText = ExcludedExtensionList; root.AppendChild(node); node = doc.CreateElement("SourceNewer"); node.InnerText = SourceNewer.ToString(); root.AppendChild(node); node = doc.CreateElement("SourceMissing"); node.InnerText = SourceMissing.ToString(); root.AppendChild(node); node = doc.CreateElement("DestNewer"); node.InnerText = DestNewer.ToString(); root.AppendChild(node); node = doc.CreateElement("DestMissing"); node.InnerText = DestMissing.ToString(); root.AppendChild(node); node = doc.CreateElement("BackupMode"); node.InnerText = BackupMode.ToString(); root.AppendChild(node); node = doc.CreateElement("Template"); node.InnerText = Template.ToString(); root.AppendChild(node); node = doc.CreateElement("ShowOnlyDifferentFiles"); node.InnerText = ShowOnlyDifferentFiles.ToString(); root.AppendChild(node); // save context menu entries node = doc.CreateElement("ContextMenuEntries"); for (int i = 0; i < ContextMenu.Count; i++) { string[] cme = ContextMenu[i].Split('\t'); XmlNode pathNode = doc.CreateElement("ContextMenuEntry"); attr = doc.CreateAttribute("caption"); attr.Value = cme[0]; pathNode.Attributes.Append(attr); attr = doc.CreateAttribute("file"); attr.Value = cme[1]; pathNode.Attributes.Append(attr); if (i == ContextDblClickIdx) { attr = doc.CreateAttribute("DblClick"); //attr.Value = cme[1]; pathNode.Attributes.Append(attr); } node.AppendChild(pathNode); } root.AppendChild(node); doc.AppendChild(root); doc.Save(fileName); }