Scripting.FileSystemObject question....

Results 1 to 4 of 4

Thread: Scripting.FileSystemObject question....

  1. #1
    Luke Penca Guest

    Default Scripting.FileSystemObject question....

    I want to have a dynamic reference to text files located on the server based upon a catalog variable passed in the URL.<BR><BR> However, as coded, line 3 fails with the message "Unterminated string constant". I know that I can&#039t use an ASP output variable like that, but I am clueless as to what to try next.<BR><BR> Any thoughts, recommendations, work-arounds or better ways of doing this are greatly appreciated.<BR><BR><BR><BR>1. &#060;% RScatalog=request.querystring("catalog") %&#062;<BR>2. &#060;% Set MyFileObject=Server.CreateObject("Scripting.FileSy stemObject")<BR>3. Set MyTextFile=MyFileObject.OpenTextFile("c:physical&# 060;%= RScatalog %&#062;.txt")<BR>4. WHILE NOT MyTextFile.AtEndOfStream<BR>5. Response.Write("&nbsp;&nbsp;"&MyTextFile.ReadAll)< BR>6. WEND<BR>7. MyTextFile.Close %&#062;

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Scripting.FileSystemObject question....

    Should be:<BR>Set MyTextFile=MyFileObject.OpenTextFile("c:physical\" & RScatalog & ".txt")<BR><BR>Just use the ampersand for string concatenation! :) Hope this answers your question!<BR><BR>Oh, the reason why &#060;%=RSCatalog%&#062; fails is the &#060;% ... %&#062; denotes ASP script inside. You are already inside an ASP script block at that point. You can&#039t have ASP script blocks inside ASP script blocks. So, if you are already in a script block, it is just a variable, and use it as such. Hope this answers your question!<BR>

  3. #3
    Luke Penca Guest

    Default RE: Scripting.FileSystemObject question....

    I got the following error when I tried that.......<BR><BR>Server object error &#039ASP 0177 : 800a004c&#039 <BR>Server.CreateObject Failed <BR>/mercury/story.asp, line 79 <BR>The operation completed successfully. <BR>

  4. #4
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Scripting.FileSystemObject question....

    Most likely the filename is not correct, or the file does not exist at that directory.<BR><BR>Do this:<BR>Dim strFileName<BR>strFileName = "C:physical\" & RScatalog & ".txt"<BR>Response.Write strFileName<BR><BR>&#039Now do your scripting stuff<BR>...<BR>FSO.Open(strFileName)<BR><BR>This way, you can see printed out the name of the file that the Scripting.FileSystemObject object is trying to open. Does that make sense?


Posting Permissions

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