
Retrieving drive letters and paths on a CD using client side VBScript
I'm posting this in the hope that someone finds this useful - if you
do, please email me with any comments / suggestions...
I recently had a problem where I needed to access a database on a CD
using just client side VBScript, but I needed the full path to the
database for ADO to find it. I find a solution by using the following
code....
function GetDriveLetter(byval dURL)
dim x
x = instr(1,lcase(dURL),"file:///")
if x > 0 then
dURL = replace(lcase(dURL),"file:///","") 'remove file part of line
GetDriveLetter = left(dURL,2)
end if
end function
function GetPath(byval pURL)
dim x
x = instr(1,lcase(pURL),"file:///")
if x > 0 then
pURL = replace(lcase(pURL),"file:///","") 'remove file part of line
x = instrrev(pURL,"/")
GetPath = left(pURL,x)
end if
end function
The functions will return the full path (or just the drive letter) of
the current page, and are designed with file urls in mind. If a
normal HTTP url is entered, they will return nothing. The idea should
also work in JavaScript, and if you'd like the same examples in
Javascript, let me know.
Shaun