コード例 #1
0
        public static ServerIcons ReadFile(string file)
        {
            var serializer = new ServerIconsSerializer();

            try
            {
                string xml;
                using (var reader = new StreamReader(file))
                {
                    xml = reader.ReadToEnd();
                    reader.Close();
                }

                return(serializer.Deserialize(xml));
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in ReadFile()");
            }

            return(new ServerIcons());
        }
コード例 #2
0
        public static bool WriteFile(string file, ServerIcons config)
        {
            var serializer = new ServerIconsSerializer();

            try
            {
                var xml = serializer.Serialize(config).OuterXml;
                using (var writer = new StreamWriter(file, false))
                {
                    writer.Write(xml);
                    writer.Flush();
                    writer.Close();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in WriteFile()");
            }

            return(false);
        }
コード例 #3
0
        public static bool WriteFile(string file, ServerIcons config)
        {
            var serializer = new ServerIconsSerializer();

            try
            {
                var xml = serializer.Serialize(config).OuterXml;
                using (var writer = new StreamWriter(file, false))
                {
                    writer.Write(xml);
                    writer.Flush();
                    writer.Close();
                }

                return true;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in WriteFile()");
            }

            return false;
        }
コード例 #4
0
        public static ServerIcons ReadFile(string file)
        {
            var serializer = new ServerIconsSerializer();

            try
            {
                string xml;
                using (var reader = new StreamReader(file))
                {
                    xml = reader.ReadToEnd();
                    reader.Close();
                }

                return serializer.Deserialize(xml);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in ReadFile()");
            }

            return new ServerIcons();
        }