Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                PrintUsage();
                return;
            }

            string option = args[0];
            string path = args[1];

            bool isFile = File.Exists(path);
            bool isDirectory = false;
            if (!isFile)
                isDirectory = Directory.Exists(path);

            if (!isFile && !isDirectory)
            {
                Console.WriteLine("指定的文件或路径不存在");
                Console.ReadKey();
                return;
            }

            Ctxr c = new Ctxr();
            if (isFile)
            {
                FileInfo file = new FileInfo(path);
                switch (option.ToLower())
                {
                    case "c2g":
                        c.ToGtf(file);
                        break;
                    case "g2c":
                        c.ToCtxr(file);
                        break;
                    default:
                        PrintUsage();
                        break;
                }
            }
            else
            {
                switch (option.ToLower())
                {
                    case "c2g":
                        string[] cFiles = GetAllFiles(new DirectoryInfo(path), ".ctxr");
                        foreach (string cSingle in cFiles)
                        {
                            FileInfo cFile = new FileInfo(cSingle);
                            c.ToGtf(cFile);
                        }
                        break;
                    case "g2c":
                        string[] gFiles = GetAllFiles(new DirectoryInfo(path), ".gtf");
                        foreach (string gSingle in gFiles)
                        {
                            FileInfo gFile = new FileInfo(gSingle);
                            c.ToCtxr(gFile);
                        }
                        break;
                    default:
                        PrintUsage();
                        break;
                }
            }

            Console.WriteLine("处理完成\r\n按任意键退出");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                PrintUsage();
                return;
            }

            string option = args[0];
            string path   = args[1];

            bool isFile      = File.Exists(path);
            bool isDirectory = false;

            if (!isFile)
            {
                isDirectory = Directory.Exists(path);
            }

            if (!isFile && !isDirectory)
            {
                Console.WriteLine("指定的文件或路径不存在");
                Console.ReadKey();
                return;
            }

            Ctxr c = new Ctxr();

            if (isFile)
            {
                FileInfo file = new FileInfo(path);
                switch (option.ToLower())
                {
                case "c2g":
                    c.ToGtf(file);
                    break;

                case "g2c":
                    c.ToCtxr(file);
                    break;

                default:
                    PrintUsage();
                    break;
                }
            }
            else
            {
                switch (option.ToLower())
                {
                case "c2g":
                    string[] cFiles = GetAllFiles(new DirectoryInfo(path), ".ctxr");
                    foreach (string cSingle in cFiles)
                    {
                        FileInfo cFile = new FileInfo(cSingle);
                        c.ToGtf(cFile);
                    }
                    break;

                case "g2c":
                    string[] gFiles = GetAllFiles(new DirectoryInfo(path), ".gtf");
                    foreach (string gSingle in gFiles)
                    {
                        FileInfo gFile = new FileInfo(gSingle);
                        c.ToCtxr(gFile);
                    }
                    break;

                default:
                    PrintUsage();
                    break;
                }
            }

            Console.WriteLine("处理完成\r\n按任意键退出");
            Console.ReadKey();
        }