1) Answer:
Refer this url : http://www.codeproject.com/Articles/18033/Phone-Directory-Implementation-Using-TRIE
2) Answer:
int count = 0;
string[] Text = File.ReadAllLines("C:/Test.txt");
for (int i = 0; i < Text.Count(); i++)
{
count += Text[i].Length;
}
3) Answer:
public static bool Replace(ref string file, ref string searchFor, ref string replaceWith)
{
try
{
//get a StreamReader for reading the file
StreamReader reader = new StreamReader(file);
//read the entire file at once
string contents = reader.ReadToEnd();
//close up and dispose
reader.Close();
reader.Dispose();
//use regular expressions to search and replace our text
contents = Regex.Replace(contents,searchFor,replaceWith);
//get a StreamWriter for writing the new text to the file
StreamWriter writer = new StreamWriter(file);
//write the contents
writer.Write(contents);
//close up and dispose
writer.Close();
writer.Dispose();
//return successful
return true;
}
catch (Exception)
{
return false;
}
}
Anu_Dgr8, if this helps please login to Mark As Answer. | Alert Moderator