Posted on: 8/15/2014 5:32:03 AM | Views : 406

Hi. I've the code below. It writes who enter my website. But as soon as a new enters my website it overwrites the text file. So how do I change the code so every session writes to the text file.?
Can it be done so it writes to a sql  and if how? 

string strName = HttpContext.Current.User.Identity.Name.ToString(); //create a string that contains the file path string strFilePath = INFO_DIR + "CS_log.txt"; //Response.Write("Writing log file to " + strFilePath + " ...");
//create stream writer object and pass it the file path StreamWriter sw = File.CreateText(strFilePath); //write user info to log sw.WriteLine("Logon time: " + DateTime.Now.ToString()); sw.WriteLine("WRX: " + Request.LogonUserIdentity.Name); sw.WriteLine("Url: " + Request.UrlReferrer); //close the stream to the file. sw.Close();
Go to the complete details ...