Exemple #1
0
        public static void Run(params string[] args)
        {
            if (args.Length < 1)
            {
                StandardUsage();
                return;
            }

            string jpegFileName = null;
            string embFileName  = null;
            string password     = null;

            for (int i = 0; i < args.Length; i++)
            {
                if (!args[i].StartsWith("-"))
                {
                    if (!args[i].EndsWith(".jpg"))
                    {
                        StandardUsage();
                        return;
                    }
                    jpegFileName = args[i];
                    continue;
                }
                if (args.Length < i + 1)
                {
                    Console.WriteLine("Missing parameter for switch " + args[i]);
                    StandardUsage();
                    return;
                }
                if (args[i].Equals("-e"))
                {
                    embFileName = args[i + 1];
                }
                else if (args[i].Equals("-p"))
                {
                    password = args[i + 1];
                }
                else
                {
                    Console.WriteLine("Unknown switch " + args[i] + " ignored.");
                }
                i++;
            }

            using (JpegExtract extractor = new JpegExtract(File.OpenWrite(embFileName), password))
            {
                extractor.Extract(File.OpenRead(jpegFileName));
            }
        }
        public static void Run(params string[] args)
        {
            if (args.Length < 1)
            {
                StandardUsage();
                return;
            }

            string jpegFileName = null;
            string embFileName = null;
            string password = null;
            for (int i = 0; i < args.Length; i++)
            {
                if (!args[i].StartsWith("-"))
                {
                    if (!args[i].EndsWith(".jpg"))
                    {
                        StandardUsage();
                        return;
                    }
                    jpegFileName = args[i];
                    continue;
                }
                if (args.Length < +1)
                {
                    Console.WriteLine("Missing parameter for switch " + args[i]);
                    StandardUsage();
                    return;
                }
                if (args[i].Equals("-e"))
                {
                    embFileName = args[i + 1];
                }
                else if (args[i].Equals("-p"))
                {
                    password = args[i + 1];
                }
                else
                {
                    Console.WriteLine("Unknown switch " + args[i] + " ignored.");
                }
                i++;
            }

            using (JpegExtract extractor = new JpegExtract(File.OpenWrite(embFileName), password))
            {
                extractor.Extract(File.OpenRead(jpegFileName));
            }
        }