Beispiel #1
0
        /// <summary>
        /// Saves the provided parts info to file.
        /// </summary>
        /// <param name="parts">An array of the parts to save to file.</param>
        public void SaveInfoToFile(PartInfo[] parts)
        {
            // Logging disabled to boost performance
            //using (LogGroup logGroup = LogGroup.StartDebug("Saving the provided parts to XML file."))
            //{
            string path = FileNamer.PartsInfoFilePath;

            //LogWriter.Debug("Path : " + path);

            if (!Directory.Exists(Path.GetDirectoryName(path)))
                Directory.CreateDirectory(Path.GetDirectoryName(path));

            using (StreamWriter writer = File.CreateText(path))
            {
                XmlSerializer serializer = new XmlSerializer(parts.GetType());
                serializer.Serialize(writer, parts);
                writer.Close();
            }
            //}
        }