Working with Text Files

<% Set FileObject = Server.CreateObject("Scripting.FileSystemObject") TestFile = Server.MapPath ("/ASPSamp") & "\samples\textwork.txt" Set OutStream= FileObject.CreateTextFile (TestFile, True, False) OutputString = "This is a test..." & Now() OutStream.WriteLine OutputString Response.Write "Wrote the string '" & OutputString & "' to the file: '" & TestFile & "'

" Set OutStream = Nothing Response.Write "Reading from file '" & TestFile & "':
" Set InStream= FileObject.OpenTextFile (TestFile, 1, False, False) While not InStream.AtEndOfStream Response.Write Instream.Readline & "
" InStream.SkipLine() Wend Set Instream=Nothing Randomize TipNumber = Int(10 * Rnd) Response.Write "

The Tip Number is: " & TipNumber & "

" strtipsfile = (Server.MapPath("/advworks") + "\tips.txt") Set InStream = FileObject.OpenTextFile (strtipsfile, 1, False, False) While TipNumber > 0 InStream.SkipLine() TipNumber = TipNumber-1 Wend TipOfTheDay = Instream.ReadLine Response.Write "The Tip of the Day is:
" & TipOfTheDay & "" Set InStream = Nothing %>