1

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.

4
  • ActiveX runs on the client and the html is on the server normally, Is your setup different? Commented Dec 6, 2016 at 9:27
  • What is the meaning by my setup different? Commented Dec 7, 2016 at 0:47
  • You can run ActiveX on the server, but it is normally run on the client. The html is sent by the server and is rendered by the browser. The actual html is not stored locally (ish - not 100% sure how the browser caches it). The javascript instructs the locally installed ActiveX to access the local (client) file system. Commented Dec 7, 2016 at 9:28
  • I know that the name of the activeX which accesses file system,it is FileSystemObject,but I am not sure how to use it .Obviously code above did not work as I expect ,it just return the desktop path such as "C:\user\desktop"; Commented Dec 9, 2016 at 2:40

1 Answer 1

1

You can do this with the following code:

var fso = new ActiveXObject("scripting.FileSystemObject");
return fso.GetAbsolutePathName(".");
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks very much. I get it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.