m_Root是文件名,可以使用相对路径。
调用调用示例:
- Response.Write(LoadFile("Test.htm"))
- Function LoadFile(m_Root)
- Dim Filename,fso,hndFile
- Filename = m_Root
- If Right(Filename, 1)<>"/" And Right(Filename, 1)<>"\" Then Filename = Filename & "/"
- Filename = Server.MapPath(Filename & m_FileName)
- Set fso = CreateObject("Scripting.FileSystemObject")
- If Not fso.FileExists(Filename) Then ShowError("模板文件" & m_FileName & "不存在!")
- set hndFile = fso.OpenTextFile(Filename)
- LoadFile = hndFile.ReadAll
- Set hndFile = Nothing
- Set fso = Nothing
- If LoadFile = "" Then ShowError("不能读取模板文件" & m_FileName & "或文件为空!")
- End Function