Public Class conn
Function WriteFile(ByVal strText As String, ByVal strContent As String, ByVal strAuthor As String)
Dim path As String = HttpContext.Current.Server.MapPath("news/")
Dim code As Encoding = Encoding.GetEncoding("gb2312")
Dim temp As String = HttpContext.Current.Server.MapPath("news/text.html")
Dim sr As StreamReader
sr = StreamReader.Null
Dim sw As StreamWriter
sw = StreamWriter.Null
Dim str As String = ""
Try
sr = New StreamReader(temp, code, True)
str = sr.ReadToEnd()
Catch ex As Exception
HttpContext.Current.Response.Write(ex.Message)
HttpContext.Current.Response.End()
sr.Close()
End Try
Dim htmlfilename As String = DateTime.Now.ToString("yyymmddhhmmss") + ".html"
str = str.Replace("ShowArticle", strText)
str = str.Replace("biaoti", strText)
str = str.Replace("content", strContent)
str = str.Replace("author", strAuthor)
Try
sw = New StreamWriter(path + htmlfilename, False, code)
sw.Write(str)
sw.Flush()
Catch ex As Exception
HttpContext.Current.Response.Write(ex.Message)
HttpContext.Current.Response.End()
Finally
sw.Close()
End Try
Return True
End Function
Function WriteFile(ByVal strText As String, ByVal strContent As String, ByVal strAuthor As String)
Dim path As String = HttpContext.Current.Server.MapPath("news/")
Dim code As Encoding = Encoding.GetEncoding("gb2312")
Dim temp As String = HttpContext.Current.Server.MapPath("news/text.html")
Dim sr As StreamReader
sr = StreamReader.Null
Dim sw As StreamWriter
sw = StreamWriter.Null
Dim str As String = ""
Try
sr = New StreamReader(temp, code, True)
str = sr.ReadToEnd()
Catch ex As Exception
HttpContext.Current.Response.Write(ex.Message)
HttpContext.Current.Response.End()
sr.Close()
End Try
Dim htmlfilename As String = DateTime.Now.ToString("yyymmddhhmmss") + ".html"
str = str.Replace("ShowArticle", strText)
str = str.Replace("biaoti", strText)
str = str.Replace("content", strContent)
str = str.Replace("author", strAuthor)
Try
sw = New StreamWriter(path + htmlfilename, False, code)
sw.Write(str)
sw.Flush()
Catch ex As Exception
HttpContext.Current.Response.Write(ex.Message)
HttpContext.Current.Response.End()
Finally
sw.Close()
End Try
Return True
End Function