I am working on winforms application in C#. What I want to achieve is to get a file from user for which I am using the following code:
OpenFileDialog dlg =
Try this code:
private void Browse_Click(object sender, EventArgs e)
{
var fdlg = new OpenFileDialog();
fdlg.Title = "Open a file";
fdlg.InitialDirectory = "c:/";
fdlg.Filter = "all files(*.*)|*.*|all files(*.)|*.*";
fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK)
{
filetxt.Text = fdlg.FileName;
}
}