'Undefined' Error for "Scripting.FileSystemObject"

P

pbd22

Hi -

I have code that automatically fills tabs on a page. In some cases, a
URL path won't be correct (the folder and files don't exist) and, in
these cases, I want to catch these exceptions and move the logic to
the next instance in the loop (again, testing if the URL path exists).

I have a check_path function for these cases with the following code:

var oFSO = new ActiveXObject("Scripting.FileSystemObject");

if (!oFSO.FolderExists(fold)) {
alert("Folder does not exist!");
}

else if (!oFSO.FileExists(file))
{
alert("File does not exist!");
}

The problem is that the first line keeps causing the logic to fail.
when i try/catch the code, I get an "undefined" error that seems
to come from the ActiveXObject("Scripting.FileSystemObject") part.

My Question(s) Is:

a) Is this the best way to test to see if a URL path exists in
javascript?
b) If it is, why does the oFSO = new ActiveXObject... part keep
throwing an 'undefined' error?

I thank you.
 
V

VK

I have a check_path function for these cases with the following code:

var oFSO = new ActiveXObject("Scripting.FileSystemObject");

However obvious it may be:
You can get local file access this way only:
1) for lowest security level
2) only for IE

So if you are trying to use it for a web-page then it doesn't work.

If you are using it for local pages / custom security settings for IE
then the current security settings are still too high to use FSO: trop
them further down. For a test:

try {
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
}
catch (SecurityException) {
window.alert(SecurityException.message);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top