private void button_pptopen_Click(object sender, EventArgs e) { string filepath = ""; OpenFileDialog op = new OpenFileDialog(); op.Title = "请选择教学资源文件"; //op.Filter = "All Files(*.*)|*.*|ppt Files(*.ppt)|*.ppt|word 2007 Files(*.doc)|*.doc|excel 2007 Files(*.xls)|*.xls|word Files(*.docx)|*.docx|excel Files(*.xlsx)|*.xlsx"; op.Filter = "ppt Files(*.ppt,*.pptx)|*.ppt;*.pptx"; //op.Filter = "ppt Files(*.ppt,*.pptx)|*.ppt;*.pptx|Image Files(*.jpg,*.jpeg,*.bmp,*.png,*.gif)|*.jpg;*.jpeg;*.bmp;*.png;*.gif"; if (op.ShowDialog() == DialogResult.OK) { filepath = op.FileName; string dir = filepath.Substring(0, filepath.LastIndexOf("\\")); string fname = op.SafeFileName; string extension = Path.GetExtension(op.FileName); } else { return; } if (myppt == null) { myppt = new MyPPT(); myppt.PPTOpen(filepath); } else { myppt.PPTClose(); myppt.PPTOpen(filepath); } }