【发布时间】:2009-07-11 00:18:48
【问题描述】:
我正在使用 System.IO.FIle.ReadAllText() 来获取我为电子邮件内容创建的一些模板文件的内容。然后我想对文件中的某些标记进行替换,以便可以向模板添加动态内容。
这是我的代码,在我看来它应该可以正常工作......
Dim confirmUrl As String = Request.ApplicationPath & "?v=" & reg.AuthKey
Dim text As String = IO.File.ReadAllText( _
ConfigurationManager.AppSettings("sign_up_confirm_email_text").Replace("~", _
Request.PhysicalApplicationPath))
Dim html As String = IO.File.ReadAllText( _
ConfigurationManager.AppSettings("sign_up_confirm_email_html").Replace("~", _
Request.PhysicalApplicationPath))
text.Replace("%%LINK%%", confirmUrl)
text.Replace("%%NAME%%", person.fname)
html.Replace("%%LINK%%", confirmUrl)
html.Replace("%%NAME%%", person.fname)
由于某种原因,我无法使 %%LINK%% 和 %%NAME%% Replace() 调用正常工作。我检查了它是否与编码相关,所以我将每个文件都设为 UTF-8。并且还使用了 ReadAllText(String, Encoding) 的强制编码重载,仍然没有骰子。有什么想法吗?
【问题讨论】: