Last updated: August 26, 2026.
A TextStream reads or writes text through Scripting.FileSystemObject. Use a fixed server-side path and choose the required character encoding deliberately.
<%
Const ForReading = 1
Const TristateTrue = -1
Dim fso, stream, path, contents
Set fso = Server.CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/App_Data/message.txt")
Set stream = fso.OpenTextFile(path, ForReading, False, TristateTrue)
contents = stream.ReadAll
stream.Close
Response.Write Server.HTMLEncode(contents)
%>TristateTrue opens Unicode text; TristateFalse uses the system ASCII code page. For UTF-8, use ADODB.Stream with its Charset property. Never open a path supplied directly by a request.