LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Bad File Handle

CVI8.0: My application uses "ArrayToFile()" function a lot, to write variable length strings
on 16 different files. I found that some times some strings were not written!
Running the application through CVI IDE, that is running it in debug mode, an error arises:
"NON-FATAL ERROR Library error -3, Bad File Handle".
The same problem arises if I use other functions like "OpenFile(),WriteFile() and CloseFile()".
I don't know why the system gives a "bad file handle" error, as the handle integer returned
in this case, has more less the same value I get when it works properly (ex: 0x1D4, 0x1C8..)
At the moment I made a simple work around: I use the "GetFmtIOError()" after a WriteFile() call,
and when it returns an error, I repeat the loop so: close file, open and write again
until no error arises...
Can anyone help me understanding why the system gives me this kind of error?
Where could I be wrong?
 
Thank you in advance!
Regards.
Alex Tardivo
S.H.D. (Italy) Cuneo
0 Kudos
Message 1 of 4
(4,366 Views)
Are you using the NI OpenFile, WriteFile ... calls, or the Win32 SDK calls?
0 Kudos
Message 2 of 4
(4,337 Views)
We are using OpenFile(), WriteFile() e CloseFile() calls.
0 Kudos
Message 3 of 4
(4,316 Views)

Hello Alex,

do you see this problem on several systems, or only one system?

Do you get the "Bad file handle" error when using the ArryToFile function? Seems strange to me since you have to specify the file by giving the pathname, not the filehandle...

0 Kudos
Message 4 of 4
(4,310 Views)