Thursday 24 May 2012

Invalid file name message.

This is the error message you normally get when you use the the wrong file convention, As in the example below I used "\" instead of "\\" in the file path, as AX only excepts "\\":

static void ReadingFile(Args _args)
{
    TextIo      inputFile;
    //This syntax is for reading file in a local machine, we always use "\\" instead of "\"
    // AX does not read "\"
    inputFile = new TextIo("C:\test.txt", 'R');
    if (inputFile)
    {
        info("File found");
    }
}






















Solution:

static void ReadingFile(Args _args)
{
    TextIo      inputFile;
    //This syntax is for reading file in a local machine, we always use "\\" instead of "\"
    // AX does not read "\"
    inputFile = new TextIo("C:\\test.txt", 'R');
    if (inputFile)
    {
        info("File found");
    }
}

This is the correct way. Same goes for network path, you need to use "\\\\" instead of "\\", as shown below:

static void ReadingNetworkFile(Args _args)
{
    TextIo      inputFile;
    //This syntax is for reading file in a local machine, we always use "\\" instead of "\"
    // AX does not read "\"
    inputFile = new TextIo("\\\\AXServer\\test.txt", 'R');
    if (inputFile)
    {
        info("File found");
    }
}








No comments:

Post a Comment