Get the path of a directory in HTA

108 Views Asked by At

I want the user to provide the path of a folder or directory via an input tag that is created as below:

var newinput = document.createElement('input');
newinput.type = "file";
newinput.webkitdirectory; ///I am using IE for hta so I am not sure if this will work
document.body.appendChild(newinput);
<html>
  <body>
  </body>
</html>

I want to know if webkitdirectory works with hta and if I can add it to the input after creating a new element. (I only want to get the path of a certain directory, not files in the directory)

1

There are 1 best solutions below

0
Hawimhaks On

Thanks to all of you who tried to help, I found the following solution:

function selectFolder() {
  var shell = new ActiveXObject("Shell.Application");
  var folder = shell.BrowseForFolder(0, "Select a folder:", 0, 0);
  if (folder) {
    var folderPath = folder.Self.Path;
    ///Use folderPath var here
  }
}