How to check if file exists.

Status
Not open for further replies.

martinpluss

Joined
Jun 28, 2011
Messages
30
Reaction score
0
Hi,
I'm trying to write some javascript that will check to see if a settings file exists so that I can use its contents later in the application. I have an external code execution block in the main flow and I pass the working directory to it as a parameter.

I have the following code:
Code:
function CheckFileExists()
{
var g_fso = new ActiveXObject("Scripting.FileSystemObject");

var path = arguments[0] + "\settings.ini";

if (g_fso.FileExists(path))
        {
            return "true";
        }
else
		{
			return "false";
		}
}

But this fails and the 3CXIvrServer.log shows:
Code:
Error! Module '3CX.com.OSBjsi'. Error ID 501. errmsgReferenceError: ActiveXObject is not definedline3linetxttokentxt

Any ideas how I fix my code to achieve this?
 
OK. So I ended up completely rethinking my application flow and put all file operations into a dotnet library which I now reference from the the Voice Application.

I use my custom dotnet library for all file functions (like ifexists, copy, rename etc) and it works great (although I had to blow the dust off of my vb.net skillset :D )
 
Hi Martin,

Thanks for sharing with us your experience!

Hope you have a great year!

Best regards,
 
Status
Not open for further replies.

Forum statistics

Threads
112,320
Messages
591,873
Members
165,466
Latest member
EMMEPICASA