Hi For my application, I need a code that searches for Listbox text that has the beginning and end characters
code for open text to listbox
- Stream myStream = null;
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
- openFileDialog1.InitialDirectory = "c:\\";
- openFileDialog1.Filter = "txt files (*.php)|*.php|All files (*.*)|*.*";
- openFileDialog1.FilterIndex = 2;
- openFileDialog1.RestoreDirectory = true;
- if (openFileDialog1.ShowDialog() == DialogResult.OK) {
- try {
- if ((myStream = openFileDialog1.OpenFile()) != null) {
- using(myStream) {
- textBox1.Text = File.ReadAllText(openFileDialog1.FileName);
- }
- }
- } catch (Exception ex) {
- MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
- }
- }
-
-
-
- for (int n = listBox1.Items.Count - 1; n >= 0; --n) {
- string s = listBox1.Items[n].ToString(); {
- int start = n.IndexOf("<-");
- int end = n.IndexOf("->"); {
- listBox1.Items.Remove(s);
Listbox will have text
for example
text text text
<-- text to be deleted
text to be deleted
text to be deleted ->
text text text
the program will delete everything written in <- -> and so it will stay
text text text
text text text
thank you