Exemple #1
0
        private static void ConvertFile(string fileName)
        {
            List <string> lines = File.ReadAllLines(fileName).ToList();

            StripBlankLines(ref lines);

            string data = MergeLines(ref lines);

            AdmData admFile;

            try
            {
                admFile = AdmDataConverter.GetData(data);
            }
            catch (AdmConverterException e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            string outputPath = _outputDir != "" ? Path.Combine(_outputDir, Path.GetFileNameWithoutExtension(fileName)) : Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName));

            AdmWriter writer = new AdmWriter(admFile);

            writer.Write(outputPath);

            Console.WriteLine("Converted {0} into binary format", Path.GetFileName(fileName));
        }
Exemple #2
0
        private static void ConvertFile(string fileName)
        {
            var reader = new AdmReader(fileName);

            AdmData data = null;

            try
            {
                data = reader.Read();
            }
            catch (AdmReaderException e)
            {
                _hasErrored = true;
                Console.WriteLine("File: {0}", fileName);
                Console.WriteLine(e.Message);
                Console.WriteLine("Reason: {0}", e.InnerException.Message);
                return;
            }

            string content = AdmDataConverter.GetString(data);

            string outputPath = _outputDir != "" ? Path.Combine(_outputDir, fileName + ".txt") : fileName + ".txt";

            File.WriteAllText(outputPath, content);
            Console.WriteLine("Converted {0} into a human readable format", Path.GetFileName(fileName));
        }