.Mode = 3
.Open
'' 文件名为 autosave_ + 用户名 + .txt
.LoadFromFile(Server.MapPath("autosave_"&memName&".txt"))
.Charset = "utf-8"
''.Position = 0
PostContent = .ReadText()
.Close
End With
Set objStream = NoThing
'' 输出草稿
IF PostContent<>"" Then Response.Write(PostContent)
End IF
Else
'' 保存草稿,如果草稿内容和用户名均不为空则进行保存操作
IF PostContent<>Empty AND memName<>Empty Then
'' 使用 ADODB.Stream 来进行文件操作
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Type = 2
.Mode = 3
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText= PostContent
.SaveToFile Server.MapPath("autosave_"&memName&".txt"),2
.Close
End With
Set objStream = NoThing
'' 输出保存是否成功信息
If Err.Number=0 then
Response.Write("最后于 "&Now()&" 自动保存成功")
Else
Response.Write("最后