Search code examples
javascriptdirectoryactivexobject

How can I get the folder path using FileSystemObject object in JScript?


What I tried:

function getCurrentPath(){
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    return fso.GetFolder(".").Path;
}

This code is in a HTML file. Now I want to get the folder path the HTML is in.

But it always return the desktop path.


Solution

  • You can do this with the following code:

    var fso = new ActiveXObject("scripting.FileSystemObject");
    return fso.GetAbsolutePathName(".");