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

所属分类: 网络编程 / ASP编程 阅读数: 1594
收藏 0 赞 0 分享
复制代码 代码如下:

'函数名称: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

更多精彩内容其他人还在看

IIS访问ASP页面时报错The requested resource is in use.的解决办法

IIS访问ASP页面时报错The requested resource is in use.的解决办法
收藏 0 赞 0 分享

错误类型:Provider (0x80004005)未指定的错误 的一个处理方法

一般情况下asp可以正常运行,但只要连接数据库就提示,Microsoft JET Database Engine 错误'80004005'
收藏 0 赞 0 分享

关于“未指定的错误”的问题 的比较正解的解决方法

关于“未指定的错误”的问题 的比较正解的解决方法
收藏 0 赞 0 分享

关于asp+access的安全问题分析

关于asp+access的安全问题分析
收藏 0 赞 0 分享

把RS.GetRows看得更清楚

把RS.GetRows看得更清楚
收藏 0 赞 0 分享

ASP面向对象编程探讨及比较

ASP面向对象编程探讨及比较
收藏 0 赞 0 分享

ASP错误处理

ASP错误处理
收藏 0 赞 0 分享

web文件管理器的后续开发

web文件管理器的后续开发
收藏 0 赞 0 分享

上一篇,下一篇过程代码

上一篇,下一篇过程代码
收藏 0 赞 0 分享

一小偷类!!有兴趣的可以看看

一小偷类!!有兴趣的可以看看
收藏 0 赞 0 分享
查看更多