程序基本思路:
本程序由一个模板文件和一个输入文件组成,模板文件含特定代码,所以在程序运行时可以精确地找到插入替换位置,然后读取输入文件,拿到特定的段落,替换之。
思路就是这个样子,应该不是很复杂。目前就是写出来然后节省一部分代码量,该程序还有许多限制,也就在我电脑上跑跑了。
本文就是这个程序跑出来的,然后修改了部分错误,大家感受一下。
此乃初稿,即第一天完成时的代码,后续有所改动和扩展。
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace 博客笔记自动生成 {
class Program {
#region 写入标题,时间,简介
static void r_and_w_title(string file) {
var utf8WithBom = new System.Text.UTF8Encoding(true);
StreamReader reader = new StreamReader(@"D:\Github\jtahstu.github.com\blogs\biji\biji_Template.html", utf8WithBom);
String a = reader.ReadToEnd();
StreamReader reader_input = new StreamReader(@