Control Panel
Forum
Hosting Help
ASP.NET 4 & SQL 2008 R2 Hosting
Resources
Notice
Login
Members
Shared Hosting
|
Upgrade
|
Advertise
|
Tutorials
|
AdSense revenue sharing sites
|
Exam 70-680 Practice Tests
|
Silverlight games
Total
members
:
210364
Average new registrations per day (in last 7 days):
16
New Registration:
Open
Register Now
Home
»
Questions & Answers
»
global.asax file won't write to file
global.asax file won't write to file
8/11/2010
Author:
Brian Woods
I can't get my global.asax file to write to a .txt file. This works locally. Also, I can write to a txt file from a web page, but I can't get it to work from the .asax file. Has anyone been able to get this to work? Thanks.
Answers .............
Author:
Anirudha Tamhane
Accenture
Posted Date: 10/19/2010
It simply works. Your Session_Start() event looks like this:
protected void Session_Start(object sender, EventArgs e)
{
StreamWriter writter = new StreamWriter(C:/test.txt);
for(int i=0;i<=10;i++)
{
writter.WriteLine(Wrote Line No- + i);
}
writter.Close();
}
Add the using System.IO; namespace to the Global.asax page.
The followin statement will work locally but you will need to write the (~/test.txt) insetad.
StreamWriter writter = new StreamWriter(C:/test.txt);
Reply back with the exact scenario/requirement if the above solution does not solve your problem.
You must
login
to post answer for this question.
Advertise
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies Pvt Ltd.
All Rights Reserved.