You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
I want to get a reference to the folder called "style" inside the folder I am working with. I'm suposed to get this with a path relative to the folder I am working rigth now.
To do this I can use this FSO method: getFolder(folderpath) where folderpath is a relative or absolut path to the folder I want.
The problem here is that when I enter "style" as a relative path getFolder("style") it returns an error saying that the path was not found!!! I debugged this and I figured that FSO always assumes relative paths relative to the DESKTOP folder. so this would only work if I have a folder called "style" in my desktop!!
this is not handy!! Server-Side I ignore the relative path and give it a absolute path with the Server.MapPath() method.. The problem is that Client-side I can't find something similar to this..
I noticed that all the books that I have about this try to neglect this point.. but this can't be!! I really need to know this in order to solve some problems.. if you know the answer or if you know how to get arround this tricky thing i'd appreciate and answer..
It doesn't get it relative to the desktop, it's relative to where the script is running. What host is your JavaScript running in, IE, WSH or something else? If IE is it script in the page or linked from elsewhere?
My apologies, if you are running IE then it is setting the current directory to be the desktop folder. As pointed out earlier you can use the location object and related properties along with the buildPath method to create a full path. You can also find the current directory via FSO.getFolder(".") and using the WSCript.Shell class and currentDirectory property (version 5.6 only), you can also set the current directory using this class.
YES!!! it worked heehhe
the GetFolder(".") was EXACTLY what I was looking for!! thanks man!!
I even checked the getspecialfolder functions to see if there was any special flag to return the current folder!! THX MAN :)