OpenFileDialog Class
Methods | This Package | All Packages
Encapsulates the Save As common dialog box control that allows the user to open a file.
Component
|
+--CommonDialog
|
+--FileDialog
|
+--OpenFileDialog
package com.ms.wfc.ui
public class OpenFileDialog
extends FileDialog****
Remarks
The following example sets options for an Open dialog box, displays the dialog box, and saves the names of the files the user selects in a string array:
private void btnOpen_click(Object source, Event e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.setDefaultExt("java"); //sets the default extension
ofd.setFilter("Java files (*.java)|*.java|All files (*.*)|*.*"); //sets the file filter
ofd.setFilterIndex(1); //sets the filter that will be initially selected
ofd.setInitialDir("c:\\program files"); //sets the initial directory
int dlgResult = ofd.showDialog();
if (dlgResult == DialogResult.OK) {
String[] fnames = ofd.getFileNames(); //gets the names of the files the user chose
}
}