Example #1
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("请输入要进入的磁盘:");
                string path = Console.ReadLine();
                Console.WriteLine("请输入要打开的文件路径:");
                string fileName = Console.ReadLine();

                FileFather ff = GetExtention(fileName, path + fileName);
                ff.OpenFile();
            }
        }
Example #2
0
        //根据扩展名去建立对应的文件对象,并且返回一个父类对象
        public static FileFather GetExtention(string fileName, string fullPath)
        {
            FileFather ff       = null;
            string     fileType = Path.GetExtension(fileName);

            switch (fileType)
            {
            case ".txt": ff = new TxtClass(fullPath);
                break;

            case ".wmv": ff = new WmvClass(fullPath);
                break;

            case ".jpg": ff = new JpgClass(fullPath);
                break;
            }
            return(ff);
        }