/// <summary> /// Obtain configuration from a file. If the file name is not supplied the the default /// path of Constants.Data_DIR\netlog.json is used /// </summary> public static NetLogConfiguration FromFile(string filename=null) { if (filename == null) { filename = Constants.DATA_DIR + @"\netlog.json"; } NetLogConfiguration configuration = new NetLogConfiguration(); try { string configurationData = File.ReadAllText(filename); configuration = JsonConvert.DeserializeObject<NetLogConfiguration>(configurationData); configuration.dataPath = filename; } catch { configuration = new NetLogConfiguration(); configuration.dataPath = filename; // See if there was old information present string oldFilename = Constants.DATA_DIR + @"\productpath"; try { string path = File.ReadAllText(oldFilename); if (path != null) { configuration.path = path; configuration.ToFile(); File.Delete(oldFilename); } } catch { } } return configuration; }
private void updateNetLogConfiguration() { NetLogConfiguration netLogConfiguration = new NetLogConfiguration(); if (!string.IsNullOrWhiteSpace(netLogPathTextBox.Text)) { netLogConfiguration.path = netLogPathTextBox.Text.Trim(); } netLogConfiguration.ToFile(); EDDI.Instance.Reload("Netlog monitor"); }
/// <summary> /// Obtain configuration from a file. If the file name is not supplied the the default /// path of Constants.Data_DIR\netlog.json is used /// </summary> public static NetLogConfiguration FromFile(string filename = null) { if (filename == null) { filename = Constants.DATA_DIR + @"\netlog.json"; } NetLogConfiguration configuration = new NetLogConfiguration(); try { string configurationData = File.ReadAllText(filename); configuration = JsonConvert.DeserializeObject <NetLogConfiguration>(configurationData); configuration.dataPath = filename; } catch { configuration = new NetLogConfiguration(); configuration.dataPath = filename; // See if there was old information present string oldFilename = Constants.DATA_DIR + @"\productpath"; try { string path = File.ReadAllText(oldFilename); if (path != null) { configuration.path = path; configuration.ToFile(); File.Delete(oldFilename); } } catch (Exception ex) { Logging.Debug("Failed to read netlog configuration", ex); } } if (configuration == null) { configuration = new NetLogConfiguration(); configuration.dataPath = filename; } return(configuration); }