利用AdoDb.Stream对象来读取UTF-8格式的文本文件_ASP教程-查字典教程网
利用AdoDb.Stream对象来读取UTF-8格式的文本文件
利用AdoDb.Stream对象来读取UTF-8格式的文本文件
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:'函数名称:ReadTextFile'作用:利用AdoDb.Stream对象来读取UTF-8格式的文本文件'-------...

复制代码 代码如下:

'函数名称:ReadTextFile

'作用:利用AdoDb.Stream对象来读取UTF-8格式的文本文件

'----------------------------------------------------

FunctionReadFromTextFile(FileUrl,CharSet)

IfFileUrl=""ORIsNull(FileUrl)Then

ReadFromTextFile=""

ExitFunction

EndIf

IfNotFLib.IsReallyPath(FileUrl)Then

FileUrl=Server.MapPath(FileUrl)

EndIf

dimstr,stm

setstm=server.CreateObject("adodb.stream")

stm.Type=2'以本模式读取

stm.mode=3

stm.charset=CharSet

stm.open

stm.loadfromfileFileUrl

str=stm.readtext

stm.Close

setstm=nothing

ReadFromTextFile=str

EndFunction

'-------------------------------------------------

'函数名称:WriteToTextFile

'作用:利用AdoDb.Stream对象来写入UTF-8格式的文本文件

'----------------------------------------------------

FunctionWriteToTextFile(FileUrl,byvalStr,CharSet)

IfFileUrl=""ORIsNull(FileUrl)Then

WriteToTextFile=""

ExitFunction

EndIf

IfNotFLib.IsReallyPath(FileUrl)Then

FileUrl=Server.MapPath(FileUrl)

EndIf

Dimstm

setstm=server.CreateObject("adodb.stream")

stm.Type=2'以本模式读取

stm.mode=3

stm.charset=CharSet

stm.open

stm.WriteTextstr

stm.SaveToFileFileUrl,2

stm.flush

stm.Close

setstm=nothing

EndFunction

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新ASP教程学习
    热门ASP教程学习
    编程开发子分类