Find the Drives in System through Javascript.

<SCRIPT language=JavaScript>
function ShowAvailableDrives()
{
document.write(GetDriveList());
}

function GetDriveList()
{
var fso, s, n, e, x;
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives);
s = "";
do
{
x = e.item();
s = s + x.DriveLetter;
s += ":- ";
if (x.DriveType == 3) n = x.ShareName;
else if (x.IsReady) n = x.VolumeName;
else n = "[Drive not ready]";
s += n + "
";
e.moveNext();
} while (!e.atEnd());

return(s);
}

</SCRIPT>
<SCRIPT language=JavaScript> ShowAvailableDrives(); </SCRIPT>


Comments

Author: Neeraj Saluja12 May 2008 Member Level: Gold   Points : 2

I tried copyint the contents into a simple HTML file and then opening it using IE. It gives the error "Object Expected"
at the line


Any clue, what went wrong ?

Author: Ulfat Hussain01 Dec 2008 Member Level: Silver   Points : 1

To Neeraj!
Please Visit the link below for more JavaScript examples.
you can also see this article there and post your questions at that site for your problem.

http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: