The VBScript FSO and URLs 
Author Message
 The VBScript FSO and URLs

I am developing a site and need to check a user data file to see if an
authorised user is logging onto the site.  The site is being developed with
MS FrontPage 98, MS Visual InterDev, running under MS IIS4 and Windows NT
4.0.

The URL for the site is http://clerks.  While this may seem largely
irrelevant, I need to access my data file with this URL
(http://clerks/data/users.dat).  Below is a code snippet:

 Set fsoISP = Server.CreateObject("Scripting.FileSystemObject")

 'Validate the User's name and password
 strUserFile = "http://clerks/data/users.dat"
 Set fileISP = fsoISP.OpenTextFile(strUserFile, ForReading, True)

 'Loop through the file until right username and password found
 Do While fileISP.AtEndOfStream <> True
  strFileLine = fileISP.ReadLine

  'split the line
  strFileArray = Split(strFileLine, ",", -1, 1)

  'Check the user's data against the file data
  If strUserName = strFileArray(0) and strPassword = strFileArray(1) then
   boolUserFound = True
   Exit Do
  End If
 Loop

 'Close the file
 fileISP.Close

OK, the problem is that it doesn't appear to be reading anything from the
file, which has led me to thinking that there may be a problem with
VBScript's FSO and URLs.  All the examples in MSDN and the VBScript HTML
Help version 4 show the FSO with "c:\...".

Does this mean that the FSO cannot be used with URLs, or am I missing
something.  I tried using the Server.URLEncode, but it still failed.

If anyone has any ideas, please e-mail me.
Many thanks,
Paul Symes



Sat, 25 Aug 2001 03:00:00 GMT  
 The VBScript FSO and URLs
The short answer is no. You have to access the files from a physical
location, d:\path\file. There are a number of ways to translate the URL into
a physical address, but you don't really provide enough information.
Assuming your script is on the same server with the same virtual root as the
file you are trying to access, you can use the Server.MapPath() method.

physAddress=server.mappath("/") & "\data\users.dat"
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set reader=fso.OpenTextFile(physAddress,1)

Dave



Sat, 25 Aug 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. The VBScript FSO and URLs

2. Submit Your VBScript URLs

3. Set FSO... VBScript, .hta

4. VBscript, FSO

5. VBSCRIPT FSO

6. FSO, VBScript, MS Outlook, Error

7. Error with FSO in VBScript/MS Outlook

8. Posting to two URLs at the same time

9. Write URLs to a log file?

10. Can't open URLs in frames in new window

11. Dynamically building URLS and encoding parameters

12. Read a URLs source into a variable / file

 

 
Powered by phpBB® Forum Software