-
-
Save vanloc0301/a99aede16e7c525c437c7871ca17db82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void btnReadFileText_Click(object sender, EventArgs e) | |
{ | |
lstImgExport.Clear(); | |
OpenFileDialog ofd = new OpenFileDialog(); | |
if (ofd.ShowDialog() == DialogResult.OK) | |
{ | |
string s = File.ReadAllText(ofd.FileName); | |
txtListKeyword.Text = s; | |
lstTextFromFile = new List<string>(); | |
// Use using StreamReader for disposing. | |
using (StreamReader r = new StreamReader(ofd.FileName)) | |
{ | |
// Use while != null pattern for loop | |
string line; | |
while ((line = r.ReadLine()) != null) | |
{ | |
lstTextFromFile.Add(line); | |
lstTextFromFileSplit = line.Split('-').ToList(); | |
} | |
} | |
} | |
else | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment