LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading and writing u16 binary file to a new file

Solved!
Go to solution

Hello all,

 

a very simple thing that I just don't seem to be able to figure out. I have a file containing 1024bytes of unsigned 16bit words. I can read it successfully with the right value  being displayed. But then I try to write these values to a new file, I can no longer read the same value (in fact it's all grayed out 0) from the newly written file. The newly written file has the right size 1024 bytes, but I don't seem to obtain the right information. I made sure the endian are the same, little-endian.

 

 Attached is my basic VI, and the .dat file is the file containing the binary information. 

 

I'm not using copy file because once I get this figure out, I'll need to append more of the Scan.dat file to one single file. 

 

Thank you!

0 Kudos
Message 1 of 3
(2,586 Views)
Solution
Accepted by topic author northPIG87

I would put some wait time between the write and the read.  It may be a good idea to actually close the file in between.

 

I have a feeling that you may not have allowed enough time to actually have the file written out before you read it again.  That or since it is still open, the file pointer is at the end of the file and you are trying to read all the bytes starting at the end, which means you get nothing.

 

Not sure of the exact issue, but those two things comes to mind.

Message 2 of 3
(2,572 Views)

Darn it..such a simple solution and I didn't notice.

 

Yup I closed the file before reading and everything is working fine now. Thank you very much!!!!!!!

0 Kudos
Message 3 of 3
(2,566 Views)