How to check if file exists.

Discussion in 'CRM / Helpdesk / App Integration' started by martinpluss, Dec 17, 2011.

Thread Status:
Not open for further replies.
  1. martinpluss

    Joined:
    Jun 28, 2011
    Messages:
    30
    Likes Received:
    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?
     
  2. martinpluss

    Joined:
    Jun 28, 2011
    Messages:
    30
    Likes Received:
    0
    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 )
     
  3. martinpluss

    Joined:
    Jun 28, 2011
    Messages:
    30
    Likes Received:
    0
  4. VAD_Support

    VAD_Support Active Member

    Joined:
    Aug 6, 2009
    Messages:
    690
    Likes Received:
    0
    Hi Martin,

    Thanks for sharing with us your experience!

    Hope you have a great year!

    Best regards,
     
Thread Status:
Not open for further replies.