G
garyusenet
Hi I have finally made progresss with my use of the open file dialog
box!
I have now made my own method that opens the dialog box and returns the
file selected.
Can you please have a quick look at the following code and tell me if
what I have done is correct and good code.
Thankyou very much : -
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SiteExtract
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string OpenFile()
{
string fileName = "";
OpenFileDialog ofd = new OpenFileDialog();
DialogResult dr = ofd.ShowDialog();
if (dr == DialogResult.OK)
{
fileName = ofd.FileName;
}
return fileName;
}
private void Form1_Load(object sender, EventArgs e)
{
string file = OpenFile();
}
}
}
box!
I have now made my own method that opens the dialog box and returns the
file selected.
Can you please have a quick look at the following code and tell me if
what I have done is correct and good code.
Thankyou very much : -
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SiteExtract
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string OpenFile()
{
string fileName = "";
OpenFileDialog ofd = new OpenFileDialog();
DialogResult dr = ofd.ShowDialog();
if (dr == DialogResult.OK)
{
fileName = ofd.FileName;
}
return fileName;
}
private void Form1_Load(object sender, EventArgs e)
{
string file = OpenFile();
}
}
}