Reading a text file

Results 1 to 2 of 2

Thread: Reading a text file

  1. #1
    Join Date
    Dec 1969

    Default Reading a text file

    Hi,<BR> I&#039m trying to put the content of a text file in a variable, using this code:<BR><BR>&#060;%Set FSO = CreateObject("Scripting.FileSystemObject")<BR>Set inFile = FSO.OpenTextFile("add.txt")<BR>textString = inFile.ReadAll<BR>inFile.Close%&#062;<BR><BR>This is the result:<BR><BR>Microsoft VBScript runtime error &#039 800a003e&#039 <BR>Input past end of file <BR>/ecomAdmin/textfile.asp, line 4 <BR><BR>What can I do to fix this? <BR>Thanks a lot<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Location of text file?

    It looks to me like the file is empty. So you open it and try to read, there is nothing to read, so you get that quite reasonable error.<BR><BR>Where do you think that file is, that you are opening? More than likely, it is "c:windowssystemadd.txt" or something akin to that. Reason: You simply opened "add.txt", so by default the file is in the same directory as where the Web server (IIS or PWS) was started.<BR><BR>You *probably* need to do <BR><BR>OpenTextFile( Server.MapPath("add.txt") )<BR><BR>in order to work with a file in the same directory as your ASP file.<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