SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member cookies'n'cream's Avatar
    Join Date
    Jun 2003
    Location
    Scotland
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get pathname of current folder?

    Is there a way to get a VBscript to return the full pathname of the current folder that it has been placed in?

    I have been trying to do this using FileSystemObject and the GetAbsolutePathname method, but I get weird results.

    I did think about writing the script to create a dummy file, place it in the current folder, and then walk the filesystem from the top down to locate the dummy file and thus the pathname. Potentially though there could be lots of folders and this kind of search (and the coding) seems a bit excessive !!

    I am sure that there must be a simple way to return the current path, and that probably I am missing something really simple (as usual, making things more complex than they need to be !!).

    Suggestions would be greatly appreciated !!

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    London
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you looked at the server.mapPath() function? This returns the physical path of the file/folder on the server. The other way is to use the request.serverVariables(APPL_PHYSICAL_PATH) variable which also returns the phyical path on the server.

    There are a couple of other ways but you are right that you don't need to do a stack of code to get the path.

    Hope this helps.

    Keir

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,264
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    It depends on how you want the path returned. You can parse any of the following to get the path:

    Request.ServerVariables("APPL_PHYSICAL_PATH") - will return physical path of the folder itself (ie c:\dirname\subdirname\...\foldername)
    Request.ServerVariables("PATH_INFO") - returns logical path of the calling file (not folder) from the webroot
    Request.ServerVariables("PATH_TRANSLATED") - same info as PATH_INFO, but physical location
    Request.ServerVariables("SERVER_NAME") - returns web root address (ie http://www.yourdomain.com)
    Request.ServerVariables("SCRIPT_NAME") - same info as PATH_NAME
    Request.ServerVariables("URL") - same info as PATH_NAME
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  4. #4
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,264
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    forgot about server.mappath....
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  5. #5
    SitePoint Member cookies'n'cream's Avatar
    Join Date
    Jun 2003
    Location
    Scotland
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks guys,
    Your comments were great ! I tried a couple of things based on your suggestions and found request.servervariables("REAL_PATH") to be perfect !!

    My script is now doing everything it should ( well - almost !!).

    Thanks loads .


Bookmarks

Posting Permissions

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