Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Writing to txt file


Message #1 by "Frode" <fstroemm@o...> on Sun, 17 Jun 2001 14:53:23
How would I go about writing data to a text file.



I want to log information about a login (ip and successful login yes/no) 

and I want to update that logfile.







Thanks



- Frode
Message #2 by "Daniel O'Dorisio" <dodorisio@h...> on Sun, 17 Jun 2001 23:05:01 -0400
look into the File System Object (FSO) you can find information on it at the

following link:

http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/doc/jsFS

OTutor.htm



here is some sample code to get you started.



Sub CreateFile()

   Dim fso, tf

   Set fso = CreateObject("Scripting.FileSystemObject")

   Set tf = fso.CreateTextFile("c:\testfile.txt", True)

   ' Write a line with a newline character.

   tf.WriteLine("Testing 1, 2, 3.")

   ' Write three newline characters to the file.

   tf.WriteBlankLines(3)

   ' Write a line.

   tf.Write ("This is a test.")

   tf.Close

End Sub



hth

daniel



Daniel O'Dorisio

dodorisio@h...

xxx-xxx-xxxx





-----Original Message-----

From: Frode [mailto:fstroemm@o...]

Sent: Sunday, June 17, 2001 2:53 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Writing to txt file





How would I go about writing data to a text file.



I want to log information about a login (ip and successful login yes/no)

and I want to update that logfile.







Thanks



- Frode



Message #3 by "Drew, Ron" <RDrew@B...> on Tue, 19 Jun 2001 11:33:50 -0400
Use  FileSystemObject...as an example...1 to read data...2 to overwrite

existing data and 8 to append...



dim strtext,objStream, objFile

   set objFile = server.CreateObject("Scripting.FileSystemObject")

   set objStream = objFile.OpenTextFile("c:\InetPub\wwwroot\xxx.txt",8)

   strtext = "<B>" & strMessage & "</b><br><br>" & _

           "<b>" & strRealname & "</b><br>" & _

           "<b>" & strCity & ", " & strState & "  " & strCountry &

"</b><br><br>" & _

           "<a href='mailto:" & strUsername & "'>" & strUsername &

"</a><br>" & _

           "<a href='" & strURL & "'>" &strURL2 & "</a><br>" & _

           "Found Us by:..... " & strhowfound & "<br>" & _

           "Private Message? " & strPrivate &

"     Was here on " & date() & "<hr><br>"     

   objStream.Write (strtext)

   objStream.Close

 set objStream = nothing

 set objFile = nothing

 set strtext = nothing



-----Original Message-----

From: Frode [mailto:fstroemm@o...]

Sent: Sunday, June 17, 2001 10:53 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Writing to txt file





How would I go about writing data to a text file.



I want to log information about a login (ip and successful login yes/no) 

and I want to update that logfile.







Thanks



- Frode




  Return to Index