Skip to content

Instantly share code, notes, and snippets.

View scorta's full-sized avatar

Nguyen Dang Duc scorta

View GitHub Profile
public struct SearchType
{
public string url;
public string title;
public string content;
public FindingEngine engine;
public enum FindingEngine { Google, Bing, GoogleAndBing };
}
public interface ISearchResult
private string HtmlSrc(string url)
{
try
{
HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create(url);
myWebRequest.Timeout = 5000; // Set time out
myWebRequest.ReadWriteTimeout = 6000; // Set Read Write time out
myWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1);Accept-Language:vi";
WebResponse myWebResponse = myWebRequest.GetResponse();
Stream ReceiveStream = myWebResponse.GetResponseStream();
// Compose a string that consists of three lines.
string lines = "First line.\r\nSecond line.\r\nThird line.";
// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
file.WriteLine(lines);
file.Close();
//In order to append an existing file, set the Boolean parameter to true, as follows:
// Example #1
// Read the file as one string.
string text = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\WriteText.txt");
// Example #2
// Read each line of the file into a string array. Each element
// of the array is one line of the file.
string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Public\TestFolder\WriteLines2.txt");