You are on page 1of 2

//------------------------ to read line from txt file

//Textreader tr = new StreamReader("date.txt");
int counter = 0;
string line; string conect ="";
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader("C:/Documents a
nd Settings/Administrator/My Documents/Visual Studio 2008/WebSites/WebSite1/help
er.ini");
while ((line = file.ReadLine()) != null)
{
if (line.Contains("Conection"))
{
Response.Write(line);
conect = line;
}
counter++;
}
file.Close();
conect = conect.Replace("Conection", "");
Response.Write(conect);

//-----------------------------------------------------------
to write in to txt file
{
string ip;
ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ip == "" || ip == null)
{
ip = Request.ServerVariables["REMOTE_ADDR"];
}
if (ip == "" || ip == null)
{
ip = Request.UserHostAddress;
}
string browser = Request.ServerVariables["HTTP_USER_AGENT"].ToString();

//in case of error log write it in the log file.
try
{
string path = "~/Error/" + DateTime.Today.ToString("dd-MM-yy") + ".t
xt";
if (!File.Exists(System.Web.HttpContext.Current.Server.MapPath(path)
))
{
File.Create(System.Web.HttpContext.Current.Server.MapPath(path))
.Close();
}
using (StreamWriter w = File.AppendText(System.Web.HttpContext.Curre
nt.Server.MapPath(path)))

WriteLine(err3).WriteLine(err1).InvariantCu lture)). w. w. string err1 = "Error Message::" + errortext. } } .WriteLine("\r\nLog Entry : "). string err2 = "Error Occured For::" + Session["User_Id"] + " Tra ced Ip::" + ip. w. DateTime. w.showErrPopup('errorMes'. w.Close(). string err3 = "Browser Used::" + browser.WriteLine(err).RegisterStartupScript("myScript".Web. w.Now. w. { w. string err = "Error in:: " + System.WriteLine("{0}". w.ToString(CultureInfo.Current.WriteLine("Error Belongs to ::" + Error_Claim).Url. w.WriteLine(err2). "<script language=JavaScript> { parent.ToString().Flush(). 'VOD Error Console' .Requ est. } } catch (Exception ex1) { Page. 'Error Occured and the admin is notified. string Error_Claim = "vinod".HttpContext.sorry for the Inconvenience' ) }</script>").WriteLine("__________________________").