这是我的代码,我知道它不是最优的,但它对我有用。
private void textBox_title1_TextChanged(object sender, EventArgs e)
{
string title1 = textBox_title1.Text;
string currentDirectory = Directory.GetCurrentDirectory();
DateTime folderDate = DateTime.Today;
string workingFolder = folderDate.ToString("ddMMMyy");
string mailingDir = ("mailingdir\\");
string indexPage = (mailingDir + "\\" + workingFolder + "\\" + "index.html");
String appdir = Path.GetDirectoryName(Application.ExecutablePath);
String title1open = Path.Combine(appdir, mailingDir, workingFolder, "index.html");
string str = File.ReadAllText(title1open, Encoding.UTF8);
str = str.Replace("[title1]", title1);
File.WriteAllText(title1open, str);
}
但是,这只会保存输入textBox_title1