By utilizing the NAS function, we have developed a function that will import a text file automatically the data into NAV.
We are using a Timer set to a specific frequency, and looking at a specific directory whether a file exists, or not. (The logic is executed only when there is a file).
Generally, the function works fine, but once in a while we get the following error message, which will hand the service, and requires me to restart the service.
You cannot use the file <<filename>> because it is already in use.
And I believe we are getting this error message because when NAV was trying to look at the file, it was still in the middle of being copied over to the import directory.
To avoid this happening from the future, is there a good way of skipping those files that are "locked" for any kind of purposes?
Thank you.
0
Comments
I dont know such a function, but I have often used this workaround:
The sending program uses a filename xy.tmp as long as it is writing to it. At the end, it renames it to xy.txt. The importing program (NAS in our case) just watches files with txt extensions.
This is also a good way to avoid corrupted files, if the sending program does not finish its process.
Hope this helps.
Thomas
This of course is just pseudo code and would need some tweaks to be used in production, but hopefully you get the idea.
I traded my sanity for a railgun
How did you set up your NAS? The same way as Job Queue and other functionality that comes with NAV?
Also, what exactly is the state of NAS after the error occured? Service terminated? Service running but doing nothing? ...
Nevertheless, you should implement one of the suggestions given by ta5 and einsTeIn.NET in addition to investigate and possibly fix that need to restart NAS.