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

请输入您要查询的考试资料:

 

标题 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/22 19:11:04