Re: fso GetCurrentFolder
From: Michael Harris \(MVP\) (mikhar_at_mvps.org)
Date: 02/09/05
- Next message: bobbyballgame: "Re: fso GetCurrentFolder"
- Previous message: Dave Anderson: "Re: How can I use function parameters in a byref manner?"
- In reply to: bobbyballgame: "Re: fso GetCurrentFolder"
- Next in thread: bobbyballgame: "Re: fso GetCurrentFolder"
- Reply: bobbyballgame: "Re: fso GetCurrentFolder"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: bobbyballgame: "Re: fso GetCurrentFolder"
- Previous message: Dave Anderson: "Re: How can I use function parameters in a byref manner?"
- In reply to: bobbyballgame: "Re: fso GetCurrentFolder"
- Next in thread: bobbyballgame: "Re: fso GetCurrentFolder"
- Reply: bobbyballgame: "Re: fso GetCurrentFolder"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|