lamber
This script reads from one text file and writes back to the same file. It is well commented and should get you off to a good start.
<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>File Incrementer</title>
</head>
<body >
<H2 align="center">File Incrementer</h2>
<%
'Dimension the variables
Dim txtFileObj ' As a file object
Dim objFSO ' As a FileSystemObject
Dim filePath ' As a logical path to the file
Dim TextStreamObj ' As a text stream object
Dim longIntCount ' As a long integer count variable
'Define constants
Const fileName = "asp_count.txt" 'file to read & write to
' Create a filesystem object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
'Map the logical path to the physical path
filePath = Server.MapPath(fileName)
'Initialise the File Object with the path and name of the text file
Set txtFileObj = objFSO.GetFile(filePath)
'Create a TextStream Object to read, create, and write to the text file
Set TextStreamObj = txtFileObj.OpenAsTextStream
'Read in the number from the text file, convert it to long integer data type
'and save it in a variable.
longIntCount = CLng(TextStreamObj.ReadAll)
'Increment the count variable
longIntCount = longIntCount + 1
'Overwrite the original text file with a new counter file
Set TextStreamObj = objFSO.CreateTextFile(filepath)
'Write the new number into the counter file
TextStreamObj.Write CStr(longIntCount)
'Release server resources
Set objFSO = Nothing
Set TextStreamObj = Nothing
Set txtFileObj = Nothing
Response.Write("<br>The count is " & longIntCount)
%>
<br>
This file is read by another <A href="File Reader.asp">page</a> too!
<br><br>
</body>
</html>