KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a program which outputs various results onto a command line console. How do I save the output to a text file using a StreamReader or other techniques? System.Collections.Generic.IEnumerable<String> lines = File.ReadAllLines(@"C:\Test\ntfs8.txt"); foreach (String r in lines.Skip(1)) { String[] token = r.Split(','); String[] datetime = token[0].Split(' '); String timeText = datetime[4]; String actions = token[2]; Console.WriteLine("The time for this array is: " + timeText); Console.WriteLine(token[7]); Console.WriteLine(actions); MacActions(actions); x = 1; Console.WriteLine("================================================"); } if (x == 2) { Console.WriteLine("The selected time does not exist within the log files!"); } System.IO.StreamReader reader = ; string sRes = reader.ReadToEnd(); StreamWriter SW; SW = File.CreateText("C:\\temp\\test.bodyfile"); SW.WriteLine(sRes); SW.Close(); Console.WriteLine("File Created"); reader.Close();
Tags (comma-separated)
Save Edits
Cancel