比如:
我想用程序打开a.txt或者Windows Media Player文件的界面,用下面的方法:FileInfo fi=new FileInfo(@"C:\Documents and Settings\Administrator\桌面\未通过调试的程序\思源时代\ConsoleApplication1\a.txt");
//FileInfo f=new FileInfo(@"C:\Program Files\Windows Media Player\wmplayer.exe");
fi.Open(FileMode.Open);
并没有出现a.txt或者Windows Media Player文件的界面呀,怎样改动代码才能打开其界面呀?
我想用程序打开a.txt或者Windows Media Player文件的界面,用下面的方法:FileInfo fi=new FileInfo(@"C:\Documents and Settings\Administrator\桌面\未通过调试的程序\思源时代\ConsoleApplication1\a.txt");
//FileInfo f=new FileInfo(@"C:\Program Files\Windows Media Player\wmplayer.exe");
fi.Open(FileMode.Open);
并没有出现a.txt或者Windows Media Player文件的界面呀,怎样改动代码才能打开其界面呀?
System.Diagnostics.Process.Start(fileName);
才是默认的用Windows来打开文件.你的那种方式只是把文件的内容读到内存,并没有用文件对应的软件打开.
只要该文件类型(以后缀名来判断)关联到某个程序,系统会自动用该程序打开文件