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

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了利用AdoDb.Stream对象来读取UTF-8格式的文本文件脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
复制代码 代码如下:

'函数名称:ReadTextFile
    '作用:利用AdoDb.Stream对象来读取UTF-8格式的文本文件
    '----------------------------------------------------
    Function ReadFromTextFile (FileUrl,CharSet)
        If FileUrl = "" OR IsNull(FileUrl) Then
            ReaDFromTextFile = ""
            ExIT Function
        End If
        If Not FLib.IsReallyPath(FileUrl) Then
            FileUrl = Server.MapPath(FileUrl)
        End If
        dim str, stm
        set stm=server.CreateObject("adodb.stream")
        stm.TyPE=2 '以本模式读取
        stm.mode=3 
        stm.charset=CharSet
        stm.open
        stm.loadfromfile FileUrl
        str=stm.readtext
        stm.Close
        set stm=nothing
        ReadFromTextFile=str
    End Function
    '-------------------------------------------------
    '函数名称:WriteToTextFile
    '作用:利用AdoDb.Stream对象来写入UTF-8格式的文本文件
    '----------------------------------------------------
    Function WriteToTextFile (FileUrl,byval Str,CharSet)   
        If FileUrl = "" OR IsNull(FileUrl) Then
            WriteToTextFile = ""
            Exit Function
        End If
        If Not FLib.IsReallyPath(FileUrl) Then
            FileUrl = Server.MapPath(FileUrl)
        End If
        Dim stm
        set stm=server.CreateObject("adodb.stream")
        stm.Type=2 '以本模式读取
        stm.mode=3
        stm.charset=CharSet
        stm.open
        stm.WriteText str
        stm.SaveToFile FileUrl,2    
        stm.flush
        stm.Close
        set stm=nothing
    End Function

脚本宝典总结

以上是脚本宝典为你收集整理的利用AdoDb.Stream对象来读取UTF-8格式的文本文件全部内容,希望文章能够帮你解决利用AdoDb.Stream对象来读取UTF-8格式的文本文件所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: