Switch to full style
ASP/ASP.net examples
Post a reply

Read and Write to file using ASP

Sat Jul 14, 2012 1:16 am

In this example we read and write counter to file using ASP page
Code:
<%
Const 
ReadConst=1
Const WriteConst=2
Dim OpenFileobj
MyFSO,MyFilePath,myCounter
MyFilePath
=Server.MapPath("myCounter.txt")
Set MyFSO Server.CreateObject("Scripting.FileSystemObject")
if 
MyFSO.fileExists(MyFilePathThen 
Set OpenFileobj 
MyFSO.OpenTextFile(MyFilePathReadConst)
myCounter OpenFileobj.ReadLine
Response
.Write myCounter 
OpenFileobj
.Close
Set OpenFileobj 
Nothing

Reading of files is over 
now let us start writing new count value to file

Set OpenFileobj 
MyFSO.OpenTextFile(MyFilePathWriteConst)
myCounter=myCounter+1
OpenFileobj
.Write(myCounter)
OpenFileobj.Close
Set OpenFileobj 
Nothing
Else
Response.Write "File does not exist"
End if 
Set MyFSO Nothing
%> 
 




Post a reply
  Related Posts  to : Read and Write to file using ASP
 File write read     -  
 Read and write CSV file     -  
 Write and Read to File In Java Example     -  
 How to read and write to CSV file from python     -  
 Write to file using php     -  
 Write Vector list to File     -  
 read from file in C++     -  
 Read csv file     -  
 javascript read file     -  
 File read by char     -  

Topic Tags

ASP Files and I/O