Forum Discussion

FICO's avatar
FICO
Community Manager
7 years ago

Permissions issue when writing lp file from mosel

We have an application written in C#, that runs a compiled Mosel model, running under Windows 10 that writes an lp file to a temporary folder. On the customer's installation machine we are receiving an IO_ERROR because Windows is blocking the compiled Mosel model from writing the file to the temporary folder. What XPRESS file needs to be given write permissions for the temporary folder?

4 Replies

  • FICO's avatar
    FICO
    Community Manager

    Are you configuring any restrictions for the Mosel model execution? Otherwise the access rights will depend on the user who is running the process.

    Would you mind sharing some further detail, in particular the statement that you are using for writing out the matrix file?

  • FICO's avatar
    FICO
    Community Manager

    Hi Susan,

    This is the statement

    exportprob(0, TemplpFile, TotalRevenue)

    TemplpFile is the path to the file. The folder part is picked up in C# as the user's default temporary folder and has a file name appended to it. The main application executable has no problems writing to the temp folder but the bim file does.

    Many thanks,

    Stewart

  • FICO's avatar
    FICO
    Community Manager

    Before trying to write out the file this way, could you try to run some experiments by adding a few lines into your Mosel source:

    1. Check whether the destination directory exists and is writeable (requires: uses "mmsystem"):

     writeln(TemplpFile)

    tdir:= pathsplit(SYS_DIR,TemplpFile)

     writeln(tdir)

     fstat:=getfstat(tdir)

     if bittest(fstat, SYS_TYP)<>SYS_DIR

       then writeln("tdir is not a directory")

     end-if

     if bittest(fstat, SYS_WRITE)<>SYS_WRITE

       then writeln("tdir is not writeable")

     end-if

    2.Check whether Mosel's temporary directory can be used for writing the file:

     tdir:=gettmpdir

     writeln(tdir)

    exportprob(0, string(tdir))

    Mosel uses the user's temporary directory as its temporary directory, so you should be seeing some similar output from the second as what you get in the first case.

  • FICO's avatar
    FICO
    Community Manager

    Thanks Susan,

    Having asked the customer's IT Group to investigate further this seems to be general permissions problem. Another (non-Mosel) operation that involves a temporary file, and which I'd been informed was working, was in fact failing due to the same issue. I wasn't aware of the mmsystem features in the code above, they will prove useful!