Jumat, 23 Agustus 2013

FileDialogBox control in Windows Forms

It is an abstract class, therefore we cannot instantiate it directly. We can use OpenFileDialog or SaveFileDialog to open a file or to save a file respectively. Just run the open or save dialog boxes is not sufficient to open or save a file, we have to use I/O streams to do these simple tasks.

OpenFileDialog

To open an existing file and see the content of that file, OpenFileDialog box is used. It is same in all window application as shown in following image:

OpenFileDialog Box Control in windows forms

To open this dialog box just add an open file dialog control from toolbox and write openFileDialog1.ShowDialog(); in the click event of button.

SaveFileDialog 

To save a file after creating of modifying you have to save that file using SaveFileDialog box at the specified location. Following figure shows the preview of SaveFileDialog box.

SaveFileDialog Box Control in windows forms

To open this dialog box the same procedure will be followed up. Just add a SaveFileDialog and write saveFileDialog1.ShowDialog(); in the click event of button.

To open these type of dialog boxes we have to create an object of respective class and then call its ShowDialog() method:
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.ShowDialog();

FolderBrowserDialog Box Control

Tidak ada komentar:

Posting Komentar