I am trying to read a jpg from an sdcard. Card opens fine and I can see the length of the file. The issue is the fStream.Read only returns a small fraction of the bytes that should have been read. I have tried multiple files. In one jpg file it is always 177 bytes, and in a different jpg file it is always 108 bytes. The files are >200kb so from samples I realize it must be done iteratively.
The issue is that it doesn’t fill the buffer on the first read, but even when I shrink the buffer to < 100 bytes the second time calling these lines I get the exception below.
fStream = new FileStream(rootDirectory + @ “\08.jpg”, FileMode.Open,FileAccess.Read);
n = fStream.Read(bBuffer, numBytesRead, 1024);
fStream.Close();
Exception System.ArgumentException - 0xfd000000 (1)
#### GadgeteerApp1.Program::GetImage [IP: 0070] ####
#### GadgeteerApp1.Program::ProgramStarted [IP: 000d] ####
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.IO.dll
Any thoughts?