writing to a file

Results 1 to 3 of 3

Thread: writing to a file

  1. #1
    pootietang Guest

    Default writing to a file

    im once again having problems (i should realyl take a class or something.. this teachign myself thing is hard) <BR><BR>I am trying to write a single line of text to a file, the following in my code:<BR><BR>set FSO2 = CreateObject("scripting.FileSystemObject")<BR>set f2 = FSO2.GetFile(Server.MapPath(tempfilename)) <BR>f2.WriteLine = "PLEASE WRITE ME TO THAT FILE MAN!" <BR>f2.Close<BR><BR>i am getting the following error<BR><BR>Microsoft VBScript runtime error &#039;800a01b6&#039; <BR><BR>Object doesn&#039;t support this property or method: &#039;WriteLine&#039; <BR><BR><BR>I looked on 4guysfromrolla.com and it specifically says that WriteLine is a valid function and you should use it when writing to a file.. wth am i doing wrong?

  2. #2
    Join Date
    Dec 1969

    Default Try it with a write...


  3. #3
    Join Date
    Dec 1969

    Default RE: writing to a file

    &#060;%<BR><BR>Const fsoForAppend = 8<BR>strFilepath = "yourfile.txt"<BR>Dim objFSO<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR>filename= Server.MapPath(strFilePath)<BR>&#039;Open the text file<BR>Dim objTextStream<BR>Set objTextStream = objFSO.OpenTextFile(filename, fsoForAppend)<BR><BR>&#039;Display the contents of the text file<BR>objTextStream.WriteLine Put the line you wnat to write here<BR><BR><BR>&#039;Close the file and clean up<BR>objTextStream.Close<BR>Set objTextStream = Nothing<BR>Set objFSO = Nothing<BR>%&#062;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts