我有一个程序,在从日志文本文件greping字符串后输出各种结果。结果显示在命令行控制台上。
因此,无论如何都要将各种输出结果生成为基于html的报告?
可以使用哪些方法转换输出? HtmlTextWriter的?转换文件需要哪些步骤?
有人可以就这些代码提出建议吗?谢谢!
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Web.UI; // The system is telling me that it does not exist in the namespace System.web....
foreach (String r in lines.Skip(1))
{
String[] token = r.Split(',');
String[] datetime = token[0].Split(' ');
String timeText = datetime[4];
Double rawSize = Convert.ToDouble(token[1]);
Double fileSize = ((rawSize / 1024) / 1024);
String actions = token[2];
String fileName = token[7];
if ((Path.GetExtension(token[7]).Contains(".exe") || (Path.GetExtension(token[7]).Contains(".msi"))))
{
Console.WriteLine("The time for this array is: " + timeText);
Console.WriteLine(token[7]);
Console.WriteLine(actions);
Console.WriteLine(fileSize);
ProgramFilter(actions, k, fileName);
x = 1;
Console.WriteLine("================================================");
}
}
答案 0 :(得分:1)
HTML是一种基于文本的格式,因此您只需输出HTML。
没有任何内容可以简单地将文本转换为HTML - 您需要确定标记的内容。
有很多选项可以做到这一点:
至于写入文件 - 再次,有几种方法可以做到这一点:
File
类FileStream