1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

read data from file 3 programs

Discussion in 'C#' started by t7584, Mar 21, 2006.

  1. #1
    asp (visual basic script) read data from file
    none of these 3 programs work. I don't understand why
    <%
    Dim fso, f, s

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fs:confused:penTextFile("c:\testfile.txt", 1)

    s = f.ReadAll
    SEMrush
    strInputSearch=s
    response.write(strInputSearch)
    s.Close
    %>

    --------------------------------------------------------------------------------

    <%
    Dim FSO, File, TextStream, S


    Set File = FSO.GetFile("c:\testfile.txt")

    Set TextStream = File.OpenAsTextStream(OpenFileForReading)

    Do While Not TextStream.AtEndOfStream

    S = S & TextStream.ReadLine & NewLine

    Loop

    TextStream.Close
    response.write(S)

    %>

    --------------------------------------------------------------------------------

    <%
    Dim FSO, TextStream, S


    Set TextStream = FSO.OpenTextFile("<%
    Dim FSO, TextStream, S


    Set TextStream = FSO.OpenTextFile("c:\testfile.txt", OpenFileForReading)

    <A NAME="closereadfromfile"></A>

    S = TextStream.ReadAll & NewLine & NewLine

    TextStream.Close

    response.write(S)

    %>

    --------------------------------------------------------------------------------

    this program, that writes into a file, works

    Dim fso, MyFile
    Set fso = CreateObject("Scripting.FileSystemObject")

    Set MyFile= fs:confused:penTextFile("c:\testfile.txt", 2)

    MyFile.WriteLine(strInputSearch)

    MyFile.Close
     
    t7584, Mar 21, 2006 IP
    SEMrush
  2. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try:

    
    <%const forreading = 1
    const tristateusedefault = -2
    
    Dim FSO, TextStream, S
    set FSO = server.createobject("Scripting.FileSystemObject")
    
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set TextStream = FSO.opentextfile("c:\testfile.txt",forreading, tristateusedefault)
    %>
    <A NAME="closereadfromfile"></A><%
    
    S = TextStream.ReadAll & NewLine & NewLine
    
    TextStream.Close
    
    response.write(S)
    
    %>
    
    Code (markup):
    FSO opentextfile is picky about arguments. Plis, I've cleaned up your code a bit - it's basically the second example, except that you don't define FSO, and you don't escape codespace for the anchor html code.
     
    vectorgraphx, Mar 22, 2006 IP
  3. phd

    phd Active Member

    Messages:
    497
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #3
    To use this type of constants you must include "adovbs.inc" file. You can also virutual include.

    The file defines all the constant like OpenFileForReading ......

    You may found in your computer just search on your PC.
     
    phd, Mar 22, 2006 IP