Exemplo n.º 1
0
        private static void AddLegacyParamTables(string uimfFilePath)
        {
            try
            {
                var fiUimfFile = new FileInfo(uimfFilePath);
                if (!fiUimfFile.Exists)
                {
                    return;
                }

                if (fiUimfFile.Directory == null)
                {
                    return;
                }

                var targetPath = Path.Combine(fiUimfFile.Directory.FullName,
                                              Path.GetFileNameWithoutExtension(fiUimfFile.Name) + "_LegacyTablesAdded.uimf");

                var fiTargetFile = new FileInfo(targetPath);
                Console.WriteLine("Duplicating " + fiUimfFile.FullName + Environment.NewLine + " to create " + fiTargetFile.FullName);

                fiUimfFile.CopyTo(fiTargetFile.FullName, true);
                fiTargetFile.Refresh();

                fiTargetFile.LastWriteTimeUtc = DateTime.UtcNow;

                var journalFilePath = targetPath + "-journal";
                if (File.Exists(journalFilePath))
                {
                    File.Delete(journalFilePath);
                }

                System.Threading.Thread.Sleep(100);

                using (var writer = new DataWriter(targetPath))
                {
                    writer.AddLegacyParameterTablesUsingExistingParamTables();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in AddLegacyParamTables: " + ex.Message);
            }
        }