/// <summary> /// starting block for the conversion /// </summary> public void ProcessDictionary() { ClarionLocation = GetLocationOfClarionCL(); if (File.Exists(ClarionLocation + "\\ClarionCl.Exe")) { var dct = string.Empty; if (AccuraFileDialog.OpenFileDialog("DCT Files (.dct)|*.dct|JSON Files (.dct)|*.json", "Select DCT File for export or Json File for import", out dct)) { return; } DctOrJsonLocation = dct; string ext = Path.GetExtension(DctOrJsonLocation); if (Path.GetExtension(DctOrJsonLocation).ToUpper() == ".DCT") { var jsonFileName = Path.GetDirectoryName(DctOrJsonLocation) + "\\" + Path.GetFileNameWithoutExtension(DctOrJsonLocation) + ".json"; ExportDictionary(); XmlDocument doc = new XmlDocument(); doc.Load(GetTempDctxName()); string json = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.Indented); WriteFile(jsonFileName, json); File.Delete(GetTempDctxName()); } else { var json = File.ReadAllText(DctOrJsonLocation); var dctxFileName = Path.GetDirectoryName(DctOrJsonLocation) + "\\" + Path.GetFileNameWithoutExtension(DctOrJsonLocation) + ".dctx"; XmlDocument newDoc = JsonConvert.DeserializeXmlNode(json); using (FileStream fs = new FileStream(dctxFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) newDoc.Save(fs); ImportDictionary(dctxFileName); } //Remove the created dictionary } }
/// <summary> /// Find out location of the clarioncl.exe folder and if the file /// exists /// </summary> /// <returns>string Location of the file</returns> string GetLocationOfClarionCL() { string clarionClLocation = AccuraFileDialog.GetClarionCLLocation(); if (clarionClLocation == null || !File.Exists(clarionClLocation + "\\ClarionCl.Exe")) { AccuraFileDialog.SelectClarionCL(out clarionClLocation); } return(clarionClLocation); }