public Form1()
{
InitializeComponent();
loadComboEmail();
}
private void loadComboEmail()
{
string path = Directory.GetCurrentDirectory();
string build = (path + "\\" + "email.txt");
string[] lines = System.IO.File.ReadAllLines(build);
comboEmail.Items.AddRange(lines);
comboEmail.SelectedIndex=0;
}
I've got a combobox that I wanted to load with the client email addresses which are stored in an text file. Using the loadComboEmail()
I read from the text file and load the Combobox
. Am I doing something that is considered bad practice by calling the loadComboEmail
at the form startup? If so, how do I properly read from the textfile and then load it into the combo, so when the form loads, it has the necessary data?