Wesite visited counter.
in my website how to count websute visited count when home page load.please give me any sample code.i'm using asp.net.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lalit MPosted Nov 25, 2009, 6:43 AM
private int GetCounterValue()
{
StreamReader ctrFile;
FileStream ctrFileW;
StreamWriter sw;
string strPath = Server.MapPath( "myappcounter.txt");
string strCounterContents;
int nCounter;
if (File.Exists(strPath))
{
ctrFile = File.OpenText(strPath);
strCounterContents = ctrFile.ReadLine().ToString();
ctrFile.Close();
nCounter = Convert.ToInt32(strCounterContents);
}
else
nCounter = 0;
nCounter++;
ctrFileW = new FileStream(strPath, FileMode.OpenOrCreate,FileAccess.Write);
sw = new StreamWriter(ctrFileW);
sw.WriteLine(Convert.ToString(nCounter));
sw.Close();
ctrFileW.Close();
return nCounter;
}
Lalit MPosted Nov 25, 2009, 3:42 AM
--------------
more info you will get from this link