For Smarties : Appending to files using

Results 1 to 2 of 2

Thread: For Smarties : Appending to files using

  1. #1
    Join Date
    Dec 1969

    Default For Smarties : Appending to files using

    Hi,<BR><BR>I have a security program that requires that any ASP page to be protected must have a certain include at the top of it (you all know how that works).<BR><BR>My problem is that I am trying to write a Directory protector, where the site administrator can select a new directory to protect and my program automatically writes the include statement to the top of all the ASP files in that directory (this stops him having to manually type the include statement into each ASP file).<BR><BR><BR><BR>To do this I am using the following code:<BR><BR><BR>For Each file in objFileColl<BR><BR>pos = instr (,".")<BR>exten = mid (,pos)<BR>if exten = ".asp" then<BR><BR>Secline = "&#060;!--#include file = &#039/Simply-Secure/;"<BR>filetp = sdir & "\" & file.Name<BR><BR><BR><BR>Open filetp For Input As #1<BR>text_in = ""<BR>Line Input #1, get_line<BR>If get_line &#060;&#062; Secline Then<BR>text_in = text_in & get_line & Chr$(13) & Chr$(10)<BR>Do<BR> Line Input #1, get_line<BR> text_in = text_in & get_line & Chr$(13) & Chr$(10)<BR>Loop Until EOF(1)<BR>Close #1<BR><BR><BR><BR>Open filetp For Output As #1<BR>Print #1, Secline & Chr$(13); ""<BR>Print #1, text_in<BR>Close #1<BR>Response.Write "File : " & filetp & " is now secured!"<BR>Else<BR>Response.Write "File : " & filetp & " was already secured!"<BR>End If<BR>Close #1<BR>next<BR><BR><BR>This code throws the error : <BR><BR>Microsoft VBScript compilation error &#039 800a0401&#039 <BR><BR>Expected end of statement <BR><BR>/sites/ss/dirprotect.asp, line 38 <BR><BR>Open filetp For Input As #1<BR>------------^<BR><BR><BR>I have got this script to work before but have lost the original source code, when I came to rewrite it I obviously made a mistake!<BR><BR>Your help is greatly appreciated.<BR><BR>James Andrews -

  2. #2
    Join Date
    Dec 1969

    Default Try using VBScript instead of VB

    &nbsp;<BR>Your code is not VBScript code, it is standard old VB.<BR><BR>Unless you are using ASP+ (plus), it would never work. (Not sure it would work with ASP+, since I think the server object model doesn&#039t change.)<BR><BR>You need to read up (a bunch) on the FileSytemObject and the methods thereon. if you don&#039t have the docs on your own machine.<BR><BR>This isn&#039t a "smarties" question...just good basic use of the ASP objects.<BR><BR>

Posting Permissions

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