Загрузка данных


private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
    string str = listBox1.SelectedItem.ToString();
    string newstr = "";
    int flag = 0; //flag определяет разделитель |
    char c;
    int k = str.Length;
    //Выделяем из строки адрес сайта
    for (int j = 0; j < k; j++)
    {
        c = str[j];
        if (flag != 0) newstr += c;
        if (c == '|') flag = 1;
    }
    //Подставляем в адресную строку адрес сайта 
    comboBox1.Text = newstr;
}

private void button7_Click(object sender, EventArgs e)
{
    // Проверяем, есть ли в списке выделенная строка
    if (listBox1.SelectedIndex == -1)
    {
        MessageBox.Show("Нет выделенной строки");
    }
    else
    {
        // Удаляем выделенную строку
        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
    }

    // Сохраняем новый список в файле
    using (StreamWriter sw = new StreamWriter("browser.ini"))
    {
        sw.WriteLine(listBox1.Items.Count.ToString());
        for (int j = 0; j < listBox1.Items.Count; j++)
        {
            sw.WriteLine(listBox1.Items[j]);
        }
    }
}