To read the article online, visit

Text Files and ASP

Let's face it, there are times when you really want to do nothing more than write a small, compact text file on the server. We've all longed to do that, and ASP makes it painfully easy. In fact, ASP allows you to do a plethora of other file-related tasks as well (for example, read the contents of a directory, display the size of a file, determine if a folder exists or not).

To do all of these nifty things, we need to use the FileSystemObject. This object is discussed in detail in Ryan S.'s article Reading/Writing Text Files in ASP. You can also list out the contents of a directory using the FileSystemObject. I strongly recommend that you also take some time reading the complete documentation of the FileSystemObject.

Now, you may be wondering why one would choose a text file approach over a database approach. Well, first off, you wouldn't choose an anti-database approach and a pro-text file approach. Rather, a wise developer would use text files to complement their databases. Sometimes databases are too cumbersome and slow to use for what we need to do. If this is the case, use a text file! There is a great article on that discusses this: In a World Of Databases, ASP and Text Files.

Another approach to using text files is to create an HTML-based "template." Ryan S. authored a great article on this interesting technique which makes use of the FileSystemObject in an article entitled Using Template Files to Create Dynamic ASP Pages.

There are many situations where text files are better suited for use over databases. The secret is to find these key times and implement the text file solution. Now, before I go, let me throw you an interesting idea: using text files as database files!! You can use ADO to connect to Comma-Delimited files. These are just text files where each column is separated by a comma, and each row is separated by a newline character. Using the FileSystemObject (FSO) you could, in theory, create tables on the fly, alter tables and such, using FSO and/or ADO. For more information on using Comma-delimited files as database tables, read Abd Shomad's article Connecting to Text-Delimited Database Files on the Fly.

Happy Programming!

Article Information
Article Title: Text Files and ASP
Article Author: Scott Mitchell
Article URL:

Copyright 2018 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers