<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FGUI_Windows_Form%2FOpen_File_Dialog</id>
		<title>Csharp/C Sharp/GUI Windows Form/Open File Dialog - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FGUI_Windows_Form%2FOpen_File_Dialog"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Open_File_Dialog&amp;action=history"/>
		<updated>2026-04-29T21:21:08Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Open_File_Dialog&amp;diff=100&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Open_File_Dialog&amp;diff=100&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Open_File_Dialog&amp;diff=101&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Open_File_Dialog&amp;diff=101&amp;oldid=prev"/>
				<updated>2010-05-26T11:33:06Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Call ShowDialog() to display an OpenFileDialog==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class MainClass {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        OpenFileDialog dlg = new OpenFileDialog();&lt;br /&gt;
        if (dlg.ShowDialog() == DialogResult.OK) {&lt;br /&gt;
            Console.WriteLine(dlg.FileName);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrates using an OpenFileDialog to prompt for a file name, and to open a file==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// ReadIn.cs -- Demonstrates using an OpenFileDialog to prompt for a&lt;br /&gt;
//              file name, and to open a file&lt;br /&gt;
//&lt;br /&gt;
//              Compile this program with the following command line:&lt;br /&gt;
//                  C:&amp;gt;csc ReadIn.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
namespace nsStreams&lt;br /&gt;
{&lt;br /&gt;
    &lt;br /&gt;
    public class ReadIn&lt;br /&gt;
    {&lt;br /&gt;
        [STAThread]&lt;br /&gt;
        static public void Main (string [] args)&lt;br /&gt;
        {&lt;br /&gt;
            OpenFileDialog fileOpen = new OpenFileDialog ();&lt;br /&gt;
            if (args.Length == 0)&lt;br /&gt;
            {&lt;br /&gt;
                fileOpen.InitialDirectory = &amp;quot;.\\&amp;quot;;&lt;br /&gt;
                fileOpen.Filter = &amp;quot;Text files (*.txt)|*.txt|All files (*.*)|*.*&amp;quot;;&lt;br /&gt;
                fileOpen.FilterIndex = 0;&lt;br /&gt;
                fileOpen.RestoreDirectory = false; //true;&lt;br /&gt;
//                if (fileOpen.ShowDialog () == DialogResult.Cancel)&lt;br /&gt;
                if (fileOpen.ShowDialog () != DialogResult.OK)&lt;br /&gt;
                {&lt;br /&gt;
                    return;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                fileOpen.FileName = args[0];&lt;br /&gt;
            }&lt;br /&gt;
            Stream strm;&lt;br /&gt;
            StreamReader reader;&lt;br /&gt;
            try&lt;br /&gt;
            {&lt;br /&gt;
                strm = fileOpen.OpenFile ();&lt;br /&gt;
                reader = new StreamReader (strm);&lt;br /&gt;
            }&lt;br /&gt;
            catch (Exception e)&lt;br /&gt;
            {&lt;br /&gt;
                string Message = e.Message + &amp;quot;\n\nCannot open &amp;quot;&lt;br /&gt;
                                 + fileOpen.FileName;&lt;br /&gt;
                MessageBox.Show (Message, &amp;quot;Open error&amp;quot;,&lt;br /&gt;
                                 MessageBoxButtons.OK,&lt;br /&gt;
                                 MessageBoxIcon.Error);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
            Console.Write (reader.ReadToEnd ());&lt;br /&gt;
            reader.Close ();&lt;br /&gt;
            strm.Close ();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==FileOk Action==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class FileDialogApp {&lt;br /&gt;
    private static OpenFileDialog ofd;&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        ofd = new OpenFileDialog();&lt;br /&gt;
        string s = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));&lt;br /&gt;
        ofd.InitialDirectory = s;&lt;br /&gt;
        ofd.FileOk += new System.ruponentModel.CancelEventHandler(ofd_OK);&lt;br /&gt;
        ofd.ShowDialog();&lt;br /&gt;
    }&lt;br /&gt;
    public static void ofd_OK(object sender,&lt;br /&gt;
        System.ruponentModel.CancelEventArgs e) {&lt;br /&gt;
        StreamReader sr = new StreamReader(ofd.FileName);&lt;br /&gt;
        string s;&lt;br /&gt;
        while ((s = sr.ReadLine()) != null) {&lt;br /&gt;
            Console.WriteLine(s);&lt;br /&gt;
        }&lt;br /&gt;
        sr.Close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Open File Dialog with file types==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
namespace nsClassLib&lt;br /&gt;
{&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.IO;&lt;br /&gt;
    using System.Windows.Forms;&lt;br /&gt;
    &lt;br /&gt;
    public class clsMainOpenFileDialog&lt;br /&gt;
    {&lt;br /&gt;
        [STAThread]&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
            OpenFileDialog ofn = new OpenFileDialog ();&lt;br /&gt;
            ofn.Filter = &amp;quot;C Sharp Files (*.cs)|*.cs|Text Files (*.txt)|*.txt&amp;quot;;&lt;br /&gt;
            ofn.Title = &amp;quot;Type File&amp;quot;;&lt;br /&gt;
            while (true)&lt;br /&gt;
            {&lt;br /&gt;
                if (ofn.ShowDialog () == DialogResult.Cancel)&lt;br /&gt;
                    return;&lt;br /&gt;
                FileStream strm;&lt;br /&gt;
                try&lt;br /&gt;
                {&lt;br /&gt;
                    strm = new FileStream (ofn.FileName, FileMode.Open, FileAccess.Read);&lt;br /&gt;
                    StreamReader rdr = new StreamReader (strm);&lt;br /&gt;
                    while (rdr.Peek() &amp;gt;= 0)&lt;br /&gt;
                    {&lt;br /&gt;
                         string str = rdr.ReadLine ();&lt;br /&gt;
                         Console.WriteLine (str);&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
                catch (Exception)&lt;br /&gt;
                {&lt;br /&gt;
                    MessageBox.Show (&amp;quot;Error opening file&amp;quot;, &amp;quot;File Error&amp;quot;,&lt;br /&gt;
                                     MessageBoxButtons.OK, MessageBoxIcon.Exclamation);&lt;br /&gt;
                }&lt;br /&gt;
                ofn.Title = &amp;quot;Next File to Type&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set Filter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class MainClass {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        OpenFileDialog dlg = new OpenFileDialog();&lt;br /&gt;
        dlg.Filter = &amp;quot;Rich Text Files (*.rtf)|*.RTF|&amp;quot; +&lt;br /&gt;
          &amp;quot;All files (*.*)|*.*&amp;quot;;&lt;br /&gt;
        if (dlg.ShowDialog() == DialogResult.OK) {&lt;br /&gt;
            Console.WriteLine(dlg.FileName);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set InitialDirectory==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class MainClass {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        OpenFileDialog dlg = new OpenFileDialog();&lt;br /&gt;
        dlg.InitialDirectory = Application.StartupPath;&lt;br /&gt;
        if (dlg.ShowDialog() == DialogResult.OK) {&lt;br /&gt;
            Console.WriteLine(dlg.FileName);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==shows browsing for a file==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
 /*&lt;br /&gt;
  Example15_1.cs shows browsing for a file&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class Example15_1 {&lt;br /&gt;
  &lt;br /&gt;
  [STAThread]&lt;br /&gt;
  public static void Main() {&lt;br /&gt;
    // create and show an open file dialog&lt;br /&gt;
  OpenFileDialog dlgOpen = new OpenFileDialog();&lt;br /&gt;
  if (dlgOpen.ShowDialog() == DialogResult.OK)&lt;br /&gt;
    {&lt;br /&gt;
    Console.Write(dlgOpen.FileName);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==shows browsing for a set of files==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  Example15_2.cs shows browsing for a set of files&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class Example15_2 &lt;br /&gt;
{&lt;br /&gt;
    [STAThread]&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    // create an open file dialog&lt;br /&gt;
    OpenFileDialog dlgOpen = new OpenFileDialog();&lt;br /&gt;
    &lt;br /&gt;
    // set properties for the dialog&lt;br /&gt;
    dlgOpen.Title = &amp;quot;Select one or more files&amp;quot;;&lt;br /&gt;
    dlgOpen.ShowReadOnly = true;&lt;br /&gt;
    dlgOpen.Multiselect = true;&lt;br /&gt;
    // display the dialog and return results&lt;br /&gt;
    if (dlgOpen.ShowDialog() == DialogResult.OK)&lt;br /&gt;
    {&lt;br /&gt;
      foreach (string s in dlgOpen.FileNames)&lt;br /&gt;
        Console.WriteLine(s);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Show the use of some of the OpenFile dialog box==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// DlgSamp.cs -- Show the use of some of the OpenFile dialog box.&lt;br /&gt;
//&lt;br /&gt;
//               Compile this program with the following command line:&lt;br /&gt;
//                   C:&amp;gt;csc DlgSamp.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
public class clsMainOpenFile&lt;br /&gt;
{&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static public void Main ()&lt;br /&gt;
    {&lt;br /&gt;
// Create the dialog box object.&lt;br /&gt;
        OpenFileDialog ofd = new OpenFileDialog ();&lt;br /&gt;
// Allow multiple file selection.&lt;br /&gt;
        ofd.Multiselect = true;&lt;br /&gt;
// Set the text for the title bar.&lt;br /&gt;
        ofd.Title = &amp;quot;Concatenate files&amp;quot;;&lt;br /&gt;
// Do not verify that the file exists.&lt;br /&gt;
        ofd.CheckFileExists = false;&lt;br /&gt;
// Do verify that the path exists.&lt;br /&gt;
        ofd.CheckPathExists = true;&lt;br /&gt;
// Add a default extension if the user does not type one.&lt;br /&gt;
        ofd.AddExtension = true;&lt;br /&gt;
// Set the default extension.&lt;br /&gt;
        ofd.DefaultExt = &amp;quot;txt&amp;quot;;&lt;br /&gt;
// Show the read-only box.&lt;br /&gt;
        ofd.ShowReadOnly = true;&lt;br /&gt;
// Show the Help button.&lt;br /&gt;
        ofd.ShowHelp = true;&lt;br /&gt;
// Call this method when the user clicks the OK (Open) button.&lt;br /&gt;
        ofd.FileOk += new CancelEventHandler (CancelOpenFile);&lt;br /&gt;
// Call this method when the user clicks the Help button.&lt;br /&gt;
        ofd.HelpRequest += new EventHandler (ShowOpenHelp);&lt;br /&gt;
// Show the dialog box.&lt;br /&gt;
        if (ofd.ShowDialog () == DialogResult.Cancel)&lt;br /&gt;
            return;&lt;br /&gt;
// Display a list of the selected files.&lt;br /&gt;
        foreach (string str in ofd.FileNames)&lt;br /&gt;
            Console.WriteLine (str);&lt;br /&gt;
    }&lt;br /&gt;
// Delegate called when the user clicks the OK (Open) button&lt;br /&gt;
    static private void CancelOpenFile (object sender, CancelEventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
// Cast the object to an OpenFileDialog object.&lt;br /&gt;
        OpenFileDialog dlg = (OpenFileDialog) sender;&lt;br /&gt;
// Show the selected files.&lt;br /&gt;
        Console.WriteLine (&amp;quot;The selected file are:&amp;quot;);&lt;br /&gt;
        foreach (string str in dlg.FileNames)&lt;br /&gt;
            Console.WriteLine (&amp;quot;\t&amp;quot; + str);&lt;br /&gt;
// Ask whether to cancel the close event.&lt;br /&gt;
        Console.Write (&amp;quot;\r\nCancel event? [y/n]: &amp;quot;);&lt;br /&gt;
        string reply = Console.ReadLine ();&lt;br /&gt;
        if (reply[0] == &amp;quot;y&amp;quot;)&lt;br /&gt;
            e.Cancel = true;&lt;br /&gt;
    }&lt;br /&gt;
// Delegate called when the user clicks the Help button.&lt;br /&gt;
    static private void ShowOpenHelp (object sender, EventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine (&amp;quot;Open your help file to the File Open topic here.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>