Advanced ASP -- Read TextFile from Server

Results 1 to 2 of 2

Thread: Advanced ASP -- Read TextFile from Server

  1. #1
    Chris Butler Guest

    Default Advanced ASP -- Read TextFile from Server

    I&#039m trying to read a textfile from a server. I can do it fine from my local drives (c,d) but can&#039t get the OpenTextFile to search for files located on the server. Is it possible to do this? Here&#039s the line of code that works for the local drives:<BR><BR>const strFileName = "c:/somefile.txt"<BR><BR>I&#039m guessing that the syntax for a server would look something like this:<BR><BR>const strFileName"\s65a1105SomeFile.txt" <BR>(where s65a1105 represents the server name)<BR><BR>Would I have to use a Server.MapPath statement?? Help please!<BR>

  2. #2
    Shedao Shai Guest

    Default RE: Advanced ASP -- Read TextFile from Server

    Yes, use Server.MapPath to get the local directory then<BR>use use this variable to find the text file.<BR><BR><BR>Here&#039s an example I made a while back:<BR><BR>&#060;%<BR>set fso = Server.CreateObject("Scripting.FileSystemObject")< BR>dim strFilePath<BR>strFilePath = Server.MapPath("/testing/filesystem")<BR><BR>response.write("strFilePath=" & strFilePath & "<BR>")<BR>strFilePath = strFilePath & "\" & "hello.txt"<BR><BR> if fso.FileExists(strFilePath) then<BR> response.write("file exists")<BR> else<BR> response.write("file doesnt&#039t exist")<BR> end if<BR><BR>Set fso = nothing<BR>%&#062;<BR><BR><BR>- Domain Shai<BR><BR>**note - the messageboard caused carriage returns in the code so<BR>keep this in mind if you use it.

Posting Permissions

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