static void Main(string[] args) { Console.WriteLine("请输入您想进入的磁盘"); string path = Console.ReadLine(); Console.WriteLine("请输入您想打开的文件"); string fileName = Console.ReadLine(); FileFather ff = GetFile(fileName, path + fileName); ff.OpenFile(); Console.ReadKey(); }
public static FileFather GetFile(string fileT, string fullpath) { FileFather f = null; string extention = Path.GetExtension(fullpath); switch (extention) { case ".txt": f = new TextClass(fullpath); break; case ".jpg": f = new JpgClass(fullpath); break; } return(f); }