ncendef

When I call ncredef to change attributes and vriables and then call either 
ncendef or ncclose it dosen't work because the temporary file was created in the
folder where the application is and not in the folder where the data file 
resides.It works if I have the data file in the same folder as the application 
and if I send a filename instead of a pathname. I would be immensely happy if 
someone could give me an answer to this puzzle.