Example #1
0
        public OverlayConfig GetConfig(string processFilePath)
        {
            var fileName = (from x in processFilePath.Split('\\')
                            where !string.IsNullOrWhiteSpace(x)
                            select x).LastOrDefault();

            var fileSize = new FileInfo(processFilePath).Length;

            fileName += fileSize;

            var retThis    = new OverlayConfig();
            var targetFile = DefaultSavePath + "\\" + fileName + ".eoc";

            if (!File.Exists(targetFile))
            {
                retThis.ProcessFilePath = processFilePath;
                return(retThis);
            }

            try
            {
                using (var fStream = File.OpenRead(targetFile))
                {
                    var formatter = new BinaryFormatter();
                    retThis = (OverlayConfig)formatter.Deserialize(fStream);
                    fStream.Close();
                }
            }
            catch
            {
                retThis.ProcessFilePath = processFilePath;
            }

            return(retThis);
        }
Example #2
0
        public void SaveConfig(OverlayConfig overlayConfig)
        {
            var fileName = (from x in overlayConfig.ProcessFilePath.Split('\\')
                            where !string.IsNullOrWhiteSpace(x)
                            select x).LastOrDefault();

            var fileSize = new FileInfo(overlayConfig.ProcessFilePath).Length;

            fileName += fileSize;

            var targetFile = DefaultSavePath + "\\" + fileName + ".eoc";

            if (File.Exists(targetFile))
            {
                var asdasd = new FileInfo(targetFile).FullName;
                File.Delete(targetFile);
            }

            using (var fStream = File.Create(targetFile))
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(fStream, overlayConfig);
                fStream.Close();
            }
        }