• 企业400电话
  • 网络优化推广
  • AI电话机器人
  • 呼叫中心
  • 全 部 栏 目

    网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    怎样读取一个文本文件的内容?
    POST TIME:2021-10-18 07:13
    Ever want to know how to display the contents of a text document using ASP. Here is a easy way to read
    from a text file

    !--Start of ASP Code---->

    %
    'by James Seymour, http://jamesdot.org

    Dim write
    Dim fileSysObj, tf, read

    ' Read the read.txt

    ' Store the file name where the Information is stored into a variable called read

    read = "read.txt"

    ' Retrieve the fullpath of the read file

    read = LEFT(Server.Mappath(Request.ServerVariables("PATH_INFO")), InStrRev(Server.Mappath
    (Request.ServerVariables("PATH_INFO")), "\&;)) read

    ' Create an instance of FileSystem Object and store it into a variable called fileSysObj

    Set fileSysObj = createObject("Scripting.FileSystemObject")

    ' Check whether the read file exists

    IF (fileSysObj.FileExists(read)) Then
    ' if the file exists, then open it for reading
    Set tf = filesysobj.OpenTextFile(read, 1)
    read = tf.ReadLine
    tf.Close
    ELSE
    ' if you can't find read.text, display default message
    read = "I can't find the file read.txt! So this is my default message."

    END IF
    %>


    ' table the displays the read.txt file
    div align="center">
    center>
    table border="0" width="40%" cellspacing="0" cellpadding="0">
    tr>
    td width="100%" bgcolor="#EEEECC">B>%=read%>/B>
    /td>
    /tr>
    tr>
    td width="100%">


    !-- End of the ASP -->


    use the code above, click and drag your mouse over the code to highlight it. Then right click on the
    highlighted code and click "Copy." Now you may paste it into your code editor.

    上一篇:用ASP做一个TOP COOL的站内搜索
    下一篇:在线用表单建立文件夹
  • 相关文章
  • 

    关于我们 | 付款方式 | 荣誉资质 | 业务提交 | 代理合作


    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信