Avinash Yoganand

Avinash Yoganand

  • NA
  • 42
  • 70.9k

Browse and upload files in windows application

Mar 8 2011 12:18 AM
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

Answers (4)