Topic List | Page List: 1 |
---|---|
Topic | Control V topic |
Yellow 07/20/20 4:35:04 PM #5: | var fileContent = string.Empty; var filePath = string.Empty; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.InitialDirectory = "c:\\"; openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { //Get the path of specified file filePath = openFileDialog.FileName; //Read the contents of the file into a stream var fileStream = openFileDialog.OpenFile(); using (StreamReader reader = new StreamReader(fileStream)) { fileContent = reader.ReadToEnd(); } } } --- ... Copied to Clipboard! |
Topic List | Page List: 1 |