Problems with Writing to a File (FileSystemObject)

Results 1 to 2 of 2

Thread: Problems with Writing to a File (FileSystemObject)

  1. #1
    Rob W Guest

    Default Problems with Writing to a File (FileSystemObject)

    I am getting the following error when I try to use the OpenAsTextStream method to open a file for appending. <BR><BR>Error: Cannot use parens when calling a Sub Line 22<BR><BR>&#060;%<BR><BR>&#039 Dimension local variables.<BR>Dim fsoObject &#039FileSystemObject<BR>Dim filObject &#039File Object<BR>Dim strEnding<BR><BR>&#039 Declare file access constants.<BR>Const ForAppending = 8<BR>Const TristateFalse = 0<BR><BR>&#039 Initialize string variable. This string will be written to the end of the file opened next.<BR>strEnding = "&#060;!--#include file=&#039"&#039end.htm&#039"&#039--&#062;"<BR><BR>&#039 Instantiate the FileSystemObject variable.<BR>Set fsoObject = Server.CreateObject( "Scripting.FileSystemObject" )<BR><BR>&#039 Using the GetFile method of fsoObject, initialize the File object.<BR>Set filObject = fsoObject.GetFile( "C:Inetpubwwwrootcopycriterion73099.asp" )<BR><BR>&#039 Use the OpenAsTextStream method to open the file for appending.<BR>filObject.OpenAsTextStream(ForAppend ing, TristateFalse)<BR><BR>&#039 Write a short string to the end of the opened file.<BR>filObject.Write strEnding<BR><BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Problems with Writing to a File (FileSystemObj

    The OpenAsTextStream returns a text stream. You need to set a text stream object equal to the text stream returned by this function:<BR><BR>Dim objTextStream<BR>Set objTextStream = filObject.OpenAsTextStream(ForAppending, TristateFalse)<BR><BR>objTextStream.Write strEnding<BR><BR>objTextStream.Close<BR><BR>Hope this helps! Happy Programming!

Posting Permissions

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