Append text into an existing file - ASP

by Nirmala 2009-11-26 09:43:54

File Appending:
The below code will help you to append text or content into an existing file using ASP.

<form method=post action=''>
<input type=text name=email><input type=submit value=Submit>
</form>
<%
Dim email
email = Request("email")
Response.Write(email)
if len(email) > 2 Then
Const Appending=8
Dim OpenFileobj, FSOobj,FilePath
FilePath=Server.MapPath("test.txt") ' located in the same directory
Set FSOobj = Server.CreateObject("Scripting.FileSystemObject")
if FSOobj.fileExists(FilePath) Then
Set OpenFileobj = FSOobj.OpenTextFile(FilePath, Appending)
OpenFileobj.WriteLine(email)
OpenFileobj.Close
Set OpenFileobj = Nothing
Else
Response.Write "File does not exist"
End if
Set FSOobj = Nothing
End if
%>

Tagged in:

1130
like
1
dislike
0
mail
flag

You must LOGIN to add comments