Sunday, May 12, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
-1
rated 0 times [  1] [ 2]  / answers: 1 / hits: 16928  / 11 Years ago, wed, august 21, 2013, 12:00:00

I want to fetch the Text data from a Text file ::



For that, I have used code like ::



 public ActionResult Log()
{
StreamReader reader = new StreamReader(Server.MapPath(~/Views/Builder/TestLogger.txt));
return View(reader);
}


I have made this text file from Log4Net.
I wat to know that How can I fetch the contents of this Text file in my View or action of MVC application.


More From » c#

 Answers
10

You can use this code:



public ActionResult Log()
{
var fileContents = System.IO.File.ReadAllText(Server.MapPath(~/Views/Builder/TestLogger.txt));
return Content(fileContents);
}

[#76245] Monday, August 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaycoborionc

Total Points: 220
Total Questions: 106
Total Answers: 120

Location: Kenya
Member since Mon, Jun 14, 2021
3 Years ago
;