Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("请输入要打开的磁盘");
            string path = Console.ReadLine();

            Console.WriteLine("请输入要打开的文件名");
            string fileName = Console.ReadLine();
            //文件的全路径:path+fileName
            FileFather ff = GetFile(fileName, path + fileName);

            ff.OpenFile();
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("请选择要进入的磁盘");
                string path = Console.ReadLine();     //D:\
                Console.WriteLine("请选择要打开的文件");
                string fileName = Console.ReadLine(); //1.txt
                //文件的全路径:path+fileName

                FileFather ff = GetFile(fileName, path + fileName);
                ff.OpenFile();
                Console.ReadKey();
            }
        }
Exemplo n.º 3
0
        public static FileFather GetFile(string fileName, string fullPath)
        {
            string     extension = Path.GetExtension(fileName);
            FileFather ff        = null;

            switch (extension)
            {
            case ".txt": ff = new TxtPath(fullPath);
                break;

            case ".jpg": ff = new JpgPath(fullPath);
                break;

            case ".wmv": ff = new WmvPath(fullPath);
                break;
            }
            return(ff);
        }
Exemplo n.º 4
0
        public static FileFather GetFile(string fileName, string fullName)
        {
            FileFather ff        = null;
            string     extension = Path.GetExtension(fileName);

            switch (extension)
            {
            case ".txt": ff = new TxtPath(fullName);
                break;

            case ".jpg": ff = new JpgPath(fullName);
                break;

            case ".avi": ff = new AviPath(fullName);
                break;
            }
            return(ff);
        }