Friday, February 10, 2012

write to file asp.net c#

public void writeToFile(string msg)
{
string fileName = "tes.txt";
string appPath = HttpContext.Current.Request.ApplicationPath;
string physicalPath = HttpContext.Current.Request.MapPath(appPath);
fileName = Path.Combine(physicalPath, fileName);
StreamWriter writer = new StreamWriter(fileName);
writer.WriteLine(msg);
writer.Flush();
writer.Close();
}

0 comments:

Post a Comment