Methods | This Package | All Packages

SaveFileDialog Class

Encapsulates the Save As common dialog box control that allows the user to specify options for saving a file.

Component
  |
  +--CommonDialog
    |
    +--FileDialog
      |
      +--SaveFileDialog

package com.ms.wfc.ui

public class SaveFileDialog
extends
FileDialog

Remarks

The following example sets options for a Save As dialog box, displays the dialog box, and stores the name the user saved the file under in a variable:


private void btnSave_click(Object source, Event e)
{
	SaveFileDialog sfd = new SaveFileDialog();
	sfd.setDefaultExt("java");	//sets the default extension
	sfd.setValidateNames(true); //enables name validation
	sfd.setCreatePrompt(true);  //prompts the user to create the file if it doesn't exist
	sfd.setInitialDir("c:\\program files");  //sets the initial directory
	int dlgResult = sfd.showDialog();
	if (dlgResult == DialogResult.OK) {
		String fname = sfd.getFileName(); //gets the name the file was stored under
		MessageBox.show(fname);
	}
}