TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Play with JavaScript : Get Details of Client Drive list
Gaurav Kumar Arora
Mar 27
2015
Code
2.8
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
The following Code snippet talks about How to obtain listing of Client System's Drive
<HTML>
<HEAD>
<SCRIPT language=JavaScript>
//Following function returns the drive list from client system
function
getClientDrives() {
var
objfs, s, n, e, x;
objfs =
new
ActiveXObject(
"Scripting.FileSystemObject"
);
e =
new
Enumerator(objfs.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 =
"<font color=red>[Other Drive-not intialized]</font>"
;
s += n +
"<br>"
;
e.moveNext();
}
while
(!e.atEnd());
return
(s);
}
</SCRIPT>
</HEAD>
<BODY>
<P>
<h1>The following is the list of available drives on Client system:</h1>
<SCRIPT language=JavaScript> document.write(getClientDrives());</SCRIPT>
</P>
</BODY>
</HTML>
Create a new file with above code and run on a browser.
JavaScript
Client Drive list