public static Configuration Load() { XmlSerializer xml = new XmlSerializer(typeof(Configuration)); string common = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string folder = Path.Combine(common, "ohSongcast"); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string path = Path.Combine(folder, "Configuration.xml"); if (!File.Exists(path)) { return(New(path)); } try { using (TextReader reader = new StreamReader(path)) { Configuration configuration = (Configuration)xml.Deserialize(reader); configuration.SetPath(path); return(configuration); } } catch (Exception) { return(New(path)); } }
private static Configuration New(string aPath) { Configuration configuration = new Configuration(); configuration.Subnet = 0; configuration.Multicast = false; configuration.Channel = (uint)(new Random().Next(65535) + 1); configuration.Ttl = 1; configuration.Latency = 100; configuration.Preset = 0; configuration.SetPath(aPath); configuration.Save(); return(configuration); }
private static Configuration New(string aPath) { Configuration configuration = new Configuration(); configuration.Subnet = 0; configuration.Multicast = false; configuration.Channel = (uint)(new Random().Next(65535) + 1); configuration.Ttl = 1; configuration.Latency = 100; configuration.Preset = 0; configuration.SetPath(aPath); configuration.Save(); return (configuration); }