eHow launches Android app: Get the best of eHow on the go.

How To

How to Create a Text File in ASP

Contributor
By eHow Contributing Writer
(0 Ratings)

Creating, reading, and writing text files in ASP is used by programmers who want to save files for future use. They can be used for configuration settings, or for reporting. A common use of text files is to log issues with applications or web servers. Creating a text file in ASP requires the use of the "Scripting.FileSystemObject" object.

Difficulty: Moderate
Instructions
  1. Step 1

    Create an object to for the new file. This object is used in the code to create the file and assign it to a variable so that it can be manipulated:
    set myFile = server.CreateObject("Scripting.FileSystemObject")

  2. Step 2

    Create the file and assign it to a variable. The newly created "myFile" object creates the file, and it needs a handler so that the program can read and write to it:
    set myFileHandler = myFile.CreateTextFile("C:\myText.txt")

  3. Step 3

    Write to the file. Now that the text file is created, you can write text to it. The following code writes one line to the file:
    myFileHandler.WriteLine("A line of text for a new file.")

  4. Step 4

    Close the file. The operating system creates a lock on the file, so no other application or process can access it. It's important to close the file, so it can be used later in the application.
    myFileHandler.Close

References

Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Internet Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Demand Media
eHow_eHow Technology and Electronics