Windows - How to append text file handling, Handling files in ASP
How to append text file handling
How to append text in aspThe below code will help you to append a text in the file.
<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
%>
The above code will append the mail id in the file test.txt, If there is no file then it will print the error "File Does not exist""
The topic on Windows - How to append text file handling is posted by - Nandhu
Hope you have enjoyed, Windows - How to append text file handlingThanks for your time