protected void Page_Load(object sender, EventArgs e)
{
int nCount = 0;
nCount = GetCounterValue();
txtDate.Text = DateTime.Now.ToShortDateString() + "---" + DateTime.Now.ToShortTimeString();
txtAgentName.Text = User.Identity.Name;
}
private int GetCounterValue()>>>HERE IS THE ERROR not all path code return value
{
StreamReader ctrFile;
FileStream ctrFileW;
StreamWriter sw;
string Path = Server.MapPath("Counter.txt");
string CounterContents;
int nCounter;
if (File.Exists(Path))
{
ctrFile = File.OpenText(Path);
CounterContents = ctrFile.ReadLine().ToString();
ctrFile.Close();
nCounter = Convert.ToInt32(CounterContents);
}
else
{
nCounter = 0;
nCounter++;
ctrFileW = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Write);
sw = new StreamWriter(ctrFileW);
sw.WriteLine(Convert.ToString(nCounter));
sw.Close();
ctrFileW.Close();
return nCounter;
}
}
}
jamshed ahmed 0 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.