Results 1 to 5 of 5

Thread: What are the TextStream Object in ASP?

  1. #1
    Join Date
    Jul 2006
    Posts
    218

    What are the TextStream Object in ASP?

    Hello friends,
    I have just started with the Active Server Pages (ASP). I have recently got some work to complete in ASP. Since, I don't know much about the ASP, I am finding very difficult to complete that job. But thought that instead of giving up, I should take help of you guys.!! Actually I want to know what are the TextStream Object in ASP? Waiting for your replies.!! Please help me soon as possible.
    ~*~Silent~Kid~*~
    "To The World You May Be Just One Person, But To One Person You May Be The World"

  2. #2
    Join Date
    Mar 2008
    Posts
    349

    Re: What are the TextStream Object in ASP?

    The TextStream object is used to access the contents of text files. I have given you the example so that you can understand it more clearly. The following code creates a text file (D:\trial.txt) and then writes some text to the file. In the example, the variable f is an instance of the TextStream object. Here is an example :
    Code:
    <% 
    dim fs, f 
    set fs=Server.CreateObject("Scripting.FileSystemObject") 
    set f=fs.CreateTextFile("D:\trial.txt",true) 
    f.WriteLine("First Program!")
    f.Close
    set f=nothing
    set fs=nothing
    %>

  3. #3
    Join Date
    Mar 2008
    Posts
    672

    Re: What are the TextStream Object in ASP?

    You will have to know the properties and methods of the TextStream object. The following are the properties and methods of it :
    • The property AtEndOfLine, returns true, if the file pointer is positioned immediately before the end-of-line marker in a TextStream file, and false if not.
    • The property Column returns the column number of the current character position in an input stream.
    • The property Line returns the current line number in a TextStream file.
    • The method Close, closes an open TextStream file.
    • The method Read, reads a specified number of characters from a TextStream file and returns the result.
    • The method Write, writes a specified text to a TextStream file.
    • The method Skip, skips a specified number of characters when reading a TextStream file.

  4. #4
    Join Date
    Nov 2008
    Posts
    996

    Re: What are the TextStream Object in ASP?

    I have given you the example below, in which I have created a new text file trial.txt and write some text to it. before using the CreateTextFile method to create a new text file, you will have to create an instance of the FilesystemObject object. The CreateTextFile returns a TextStream object that we will use to write some text to the file. Here is the coding for that example :
    Code:
    <%
    Dim objFSO, objTStream
    'Create an instance of the FileSystemObject object
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    'Create a text file named myFile.txt, replacing any existing one with the same name
    Set objTStream = objFSO.CreateTextFile("C:\trial.txt", True)
    'Write some text to the file
    objTStream.WriteLine("Learn ASP Tutorials!")
    objTStream.WriteBlankLines(1)
    objTStream.WriteLine("The TextStream Object")
    objTStream.WriteBlankLines(2)
    objTStream.WriteLine("The TextStream object provides sequential access to the contents of text files.")
    'Close the TextStream object
    objTStream.Close
    'Free up resources
    Set objTStream = nothing
    Set objFSO = nothing
    %>

  5. #5
    Join Date
    Aug 2006
    Posts
    227

    Re: What are the TextStream Object in ASP?

    You can also create the TextStream Object using the OpenAsTextStream Method of file object. You can check the example for looking it :
    Code:
    <%
    dim strpathinfo,strphysicalpath
    strvirtualpath=request.servervariables("Path_details")
    strphysicalpath=server.mapPath(strvirtualpath)
    
    dim objFSO,objFile,objTextStream
    set objFSO=createobject("scripting.filesystemobject")
    set objFile=objFSO.getfile(strphysicalpath)
    Set objTextStream = objFile.OpenAsTextStream(Forreading,TrisatteUseDefault)
    %>
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

Similar Threads

  1. Replies: 6
    Last Post: 06-06-2011, 01:34 AM
  2. Replies: 3
    Last Post: 08-01-2011, 06:20 AM
  3. How to use TextStream in VBScript?
    By Deward in forum Software Development
    Replies: 3
    Last Post: 16-12-2010, 06:17 AM
  4. Object reference not set to an instance of an object
    By KAIRU26 in forum Software Development
    Replies: 3
    Last Post: 05-09-2009, 08:14 PM
  5. Object test = new Object() <-- Java, best way in C++
    By ADISH in forum Software Development
    Replies: 3
    Last Post: 25-10-2008, 02:32 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,263,331.67547 seconds with 16 queries