Hey, I think you must need to make use of the code below. I have created it by modifying the code of your. So, make use of it and solve the problem of your.
Code:
private void delete_BTN_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you want to delete this entry: \ r\ n" + EntryName, "", butoon.OkCancel) == DialogResult.OK)
{
string[] str = File.ReadAllLines(@ ". / file.ini");
string cancel = theList_CBOX.SelectedItem.ToString();
int j = 0;
string[] test = new string[(theList_CBOX.Items.Count)-1];
StreamWriter writer = new StreamWriter(Environment.ExpandEnvironmentVariables("% temp%") + @ "\ temp");
foreach (string newLine in str)
{
if (newLine.Contains(cancel + ";"))
{
string[] str1 = newLine.Split('=');
remove = Regex.Replace(str1[0], "[a-zA-Z]", "");
}
if (remove! = "")
{
if (! Regex.IsMatch(newLine, "abc" + Remove) | |! Regex.IsMatch(newLine, "def" + Remove) | |! Regex.IsMatch(newLine, "ghi" + Remove))
{
writer.Write(newLine);
writer.Write(Environment.NewLine);
}
}
}
writer.Close();
File.Delete(inipath);
File.Move(Environment.ExpandEnvironmentVariables("% temp%") + @ "\ temp", @ ". / file.ini");
}
}
Bookmarks