Gtk.FileSelection Class
Creates a new dialog for the user to select one or more files, directories, or cancel.

See Also: FileSelection Members


public class FileSelection : Dialog


Gtk.FileSelection should be used to retrieve file or directory names from the user. It will create a new dialog window containing a directory list, and a file list corresponding to the current working directory.

The filesystem can be navigated using the directory list or the drop-down history menu. Alternatively, the TAB key can be used to navigate using filename completion - common in text based editors such as emacs and jed.

Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog.

The functionality of the Gtk.FileSelection can be extended by using the available accessors to the buttons and drop downs.

C# Example

using System;
using Gtk;

class FileSelectionSample
	Label lbl;
	FileSelection fs;

	static void Main ()
		new FileSelectionSample ();

	FileSelectionSample ()
		Application.Init ();
		Window win = new Window ("FileSelectionSample");
		win.SetDefaultSize (250,200);
		win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
		VBox vbox = new VBox (true, 1);
		win.Add (vbox);
		Button btn = new Button ("Select a file.");
		btn.Clicked += new EventHandler (OnButtonClicked);
		vbox.Add (btn);
		lbl = new Label ("Selected: ");
		vbox.Add (lbl);
		win.ShowAll ()

		fs = new FileSelection ("Choose a file");
		fs.Response += new ResponseHandler (OnFileSelectionResponse);

		Application.Run ();

	void OnButtonClicked (object o, EventArgs args)
		fs.Run ();
		fs.Hide ();

	void OnFileSelectionResponse (object o, ResponseArgs args)
		if (args.ResponseId == ResponseType.Ok)
			lbl.Text = "Selected: " + fs.Filename;

	void OnWinDelete (object o, DeleteEventArgs args)
		Application.Quit ();


Namespace: Gtk
Assembly: gtk-sharp (in gtk-sharp.dll)
Assembly Versions: