using System.Windows.Forms; // ... OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog.ShowDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { string fileName = openFileDialog.FileName; // Do something with the file... }
using System.Windows.Forms; // ... SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; saveFileDialog.ShowDialog(); if (saveFileDialog.ShowDialog() == DialogResult.OK) { string fileName = saveFileDialog.FileName; // Do something with the file... }Package Library: System.Windows.Forms is the package library that contains the System ShowDialog method. It is a part of the .NET Framework and provides a set of classes for creating Windows-based applications.