Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

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
 
Old September 3rd, 2003, 07:42 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default HELP with relative paths in FileSystemObject

HI!

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..

THANK YOU VERY MUCH..
please help me! :|

Pedro

 
Old September 4th, 2003, 04:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you build the path using the properties of the window.location object?
 
Old September 4th, 2003, 07:03 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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?

--

Joe
 
Old September 4th, 2003, 07:32 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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.

--

Joe
 
Old September 4th, 2003, 11:20 AM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

You guys are great! :) gonan try that! :)

If you have any questions that I migth help please let me know. And if I am absent feel free to mail me : [email protected]

THANK YOU :))
hehe
bye

 
Old September 4th, 2003, 02:38 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

HAHAHHA!!!

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 :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with App root relative paths chroniclemaster1 ASP.NET 2.0 Basics 4 October 7th, 2008 03:34 AM
Using document() with relative paths boen_robot XSLT 4 June 4th, 2006 05:41 PM
Filesystemobject and UNC paths dlfisher1972 Pro VB 6 0 January 5th, 2006 01:44 PM
Virtual and relative paths - please explain SoC Classic ASP Basics 3 June 2nd, 2005 06:59 PM
Site root and document relative paths. nicnacs Dreamweaver (all versions) 5 October 5th, 2004 05:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.