Re: fso GetCurrentFolder

From: Michael Harris \(MVP\) (mikhar_at_mvps.org)
Date: 02/09/05


Date: Wed, 9 Feb 2005 08:57:58 -0800

bobbyballgame wrote:
> Thanks for the response.
>
> That is what I would have thought.
> but, try the following:
>
> on the desktop, create a new folder, named "New Folder" or whatever
> you prefer.

The current diretory at the OS/process level is *not* the same as the
location of the local HTML file.

 alert( document.location.pathname );

pathname will be the fully qualified path\filename of the page. From within
IE hosted client script, there is a leading / (e.g.,
/C:\somepath\mypage.htm) so you'll need to strip the leading / off yourself.

Of course, it would be better to do this as an HTA - no security issues and
no leading / on pathname.

This will give you the parent folder path...

 alert( fso.GetParentFolderName( document.location.pathname ) );

>
> Create an HTML file with the following HTML:
>
> <html>
> <head>
> <title>Test</title>
> <script>
>
> var fso = new ActiveXObject("Scripting.FileSystemObject");
>
> function DisplayLocalDir()
> {
> var f;
> f = fso.GetFolder(".");
>
> alert( "Path: " + f.Path + "\n" + "FolderName: " + f.Name );
>
> }
>
> </script>
> </head>
> <body>
> <div><span onclick="DisplayLocalDir()">What is the Local Directory
> Path?</span></div>
> </body>
> </html>
>
> and place the html file in the "New Folder" directory.
>
> Launch the page and see what comes up in the Message Box.
>
> Am I missing something?
>
> thanks again for the quick response.
>
>
>
>
> "Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in
> message news:uzhILtrDFHA.612@TK2MSFTNGP15.phx.gbl...
>> bobbyballgame wrote:
>>
>>> I am having a silly problem with a small utility that I am hoping
> someone
>>> can help me with.
>>>
>>> I have an html file that can get copied to any directory, and it
>>> will display all of the images in that folder (it actually has
>>> slightly more functionality than that, bubt that is the basics.
>>>
>>> I use html with jscript.
>>> I instantiate a "scripting.filesystemobject", and then try to
>>> enumerate
> the
>>> files in the folder directory. The only problem is that I do not
>>> know
> the
>>> syntax for specifying Current Directory. Can anyone help me out.
>>>
>>> The following works for getting the current folder :
>>> fso.GetFolder("./FolderName"); // but obviously, I do not always
>>> know
> the
>>> folder name.
>> Hi
>>
>> This should return current folder:
>>
>> fso.GetFolder(".");
>>
>>
>> --
>> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
>> Administration scripting examples and an ONLINE version of
>> the 1328 page Scripting Guide:
>> http://www.microsoft.com/technet/scriptcenter/default.mspx

-- 
Michael Harris
Microsoft.MVP.Scripting


Relevant Pages

  • Re: Some websites not detecting Flash
    ... Thanks for taking the time to read my thread, I look forward to reading your ... Initialize and Script ActiveX controls marked as safe for scripting ... > response. ... >>>>> still not detecting it. ...
    (microsoft.public.windowsxp.general)
  • Re: Cant see scripts on page.
    ... I think that "Rate this response" simply refers to "Was this post helpful ... People who use the newsgroups regulary use a newsreader such as Outlook ... >> is blocking scripts, scripting, active content. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Scripting.FileSystemObject error
    ... Response below. ... > if i'm canceling the script blocking of the av its doesn't make my server ... For example, IE allows security settings for different zones, and ... scripting, while setting Internet Zones to more restrictive protections. ...
    (microsoft.public.scripting.vbscript)
  • Re: Why are messages Blank?
    ... >> and very rarely but sometimes MS people will toss in a response. ... he is using the not so good Web Interface that ... Microsoft provides to the newsgroups. ... torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.win2000.general)
  • Re: Make a dynamical (J)script (more) static
    ... Modify this html file in that way, that it always will play i.e. ... other files from the inputbox out... ... Server-side scripting ... You get better answers in either a web authoring group or a ...
    (comp.programming)