How to use open file dialog for open a any file in csharp application

Today i tell how to use open file dialog in our application to open a text file ……

 before you use openfiledialog in your application you put button and text boxYou right following code in button click event.. OpenFileDialog OS = new OpenFileDialog();
           OS.ShowDialog();

           FileStream fs = new FileStream(OS.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
           StreamReader sr = new StreamReader(fs);
           sr.BaseStream.Seek(0, SeekOrigin.Begin);
           textBox1.Text = sr.ReadToEnd();
           sr.Close();
           fs.Close();

spot_img

Related Articles

MCQ Question on Annuity Scheme CIL 2020 Mock test -2

1. Why are coal companies moving towards outsourcing mode?A) To increase employment opportunitiesB) To reduce costs and become more competitiveC)...
Read more
MCQ Question on Annuity Policy of CIL 1. What is the primary purpose of the CIL Annuity Scheme, 2020?A)...
मजदूरी संदाय अधिनियम, 1936 (Payment of Wages Act, 1936) भारत में कर्मचारियों को उनके वेतन का समय पर और बिना...