Browse and upload files in windows application
i have a application wherein i have a browse button. when i click tht button it says index outofrange exception. i want to search for the file add that file to the form and mail through the windows form. sending mail through the form is working fine.
this is my code in the browse button click code:
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "MyComputer Open File Dialog";
fdlg.InitialDirectory = "C:\\";
fdlg.Filter = "All files(*.*)|*.*|All files(*.*)|*.*";
fdlg.RestoreDirectory = true;
txtAttachment.Text = fdlg.FileName;
//mail.Attachments.Add(new Attachment("C:\\Users\\Avinash\\Documents\\Desktop\\total_police_station_numbers.txt"));
}
please help me in this regard.
Thanks in advance,
Avinash