Complete this program-- New bie to FileStream ?
-
I'm new bie to C# application..here is my requirement goes, (a) I want to search a particular keyword inside a file. (b) let say, if a file contains text "this is sample program...". If i search "sample" inside a file, it should give the exact matching. (c) any prior articles for the same..? -------code FileStream fs = new FileStream("C:\\a.txt", FileMode.Open, FileAccess.Read); StreamReader fs1 = new StreamReader(fs); String mystring="sample"; while (string == fs1. _:doh:___ ) { Messagbox.show("Yes i got ur string .."); } --------- please reply this incomplete prog..snippet.
-
I'm new bie to C# application..here is my requirement goes, (a) I want to search a particular keyword inside a file. (b) let say, if a file contains text "this is sample program...". If i search "sample" inside a file, it should give the exact matching. (c) any prior articles for the same..? -------code FileStream fs = new FileStream("C:\\a.txt", FileMode.Open, FileAccess.Read); StreamReader fs1 = new StreamReader(fs); String mystring="sample"; while (string == fs1. _:doh:___ ) { Messagbox.show("Yes i got ur string .."); } --------- please reply this incomplete prog..snippet.
Read N chars (N = length of the string you're matching) from the filestream into a test string. Test the buffer against the search string. If they don't match delete the leading character from the test string, read a single character from the file, append it to the test string and test again. repeat until you find a match or reach the end of the file.
-
I'm new bie to C# application..here is my requirement goes, (a) I want to search a particular keyword inside a file. (b) let say, if a file contains text "this is sample program...". If i search "sample" inside a file, it should give the exact matching. (c) any prior articles for the same..? -------code FileStream fs = new FileStream("C:\\a.txt", FileMode.Open, FileAccess.Read); StreamReader fs1 = new StreamReader(fs); String mystring="sample"; while (string == fs1. _:doh:___ ) { Messagbox.show("Yes i got ur string .."); } --------- please reply this incomplete prog..snippet.
public bool FindMyText(string text) { // Initialize the return value to false by default. bool returnValue = false; // Ensure a search string has been specified. if (text.Length > 0) { // Obtain the location of the search string in richTextBox1. int indexToText = richTextBox1.Find(text); // Determine whether the text was found in richTextBox1. if(indexToText >= 0) { returnValue = true; } } return returnValue; } mahes
-
public bool FindMyText(string text) { // Initialize the return value to false by default. bool returnValue = false; // Ensure a search string has been specified. if (text.Length > 0) { // Obtain the location of the search string in richTextBox1. int indexToText = richTextBox1.Find(text); // Determine whether the text was found in richTextBox1. if(indexToText >= 0) { returnValue = true; } } return returnValue; } mahes