网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 asp中readall和loadfromfile区别
范文
    在asp读取文件中有两种方式读取文件,一种是通过fso的readall方法一种是通过adodb.stream对象的loadfromFile方法,对于两种方法详细介绍一下.
    首先看fso中的readall
    Dim fso, forasp_cn
    Set fso = CreateObject("Scripting.FileSystemObject")
    forasp_cn = fso.OpenTextFile("c:\www_forasp_cn.txt", 1)'这里1表示只读打开
    response.write forasp_cn.readall'从当前位置向后读取,直到文件结束,并将当前位置移动到文件的最后
    set forasp_cn = nothing
    上面便是fso读取一个文本内容全部内容.
    其次看adodb.stream对象的loadfromfile方法
    set srmObj = server.CreateObject("adodb.stream")
    srmObj.type=1
    srmObj.mode=3
    srmObj.open
    srmObj.Position=0
    srmObj.LoadFromFile "c:\www_forasp_cn.txt"
    srmObj.Position = 0
    srmObj.type=2
    srmObj.charset=chartype
    readfile=srmObj.readtext()
    srmObj.close
    这个是adodb.stream的读取方式
    这两个方法有什么不同FSO 不能操作二进制文件,对于大文件,使用 ReadAll 方法浪费内存资源.而adodb.stream 是二进制数据或文本的流。
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/18 0:30:52