SD Card read error

Hi

I have a problem when reading certain files of an sd card. Files that were placed on the card awhile back is reading fine, but files added to the sd card recently is giving an error when reading. A filestream is used to read the data and the error message is :

#### Exception System.IO.IOException - CLR_E_FILE_IO (1) ####
    #### Message: 
    #### Microsoft.SPOT.IO.NativeFileStream::Read [IP: 0000] ####
    #### System.IO.FileStream::Read [IP: 0028] ####
    #### testfinal.Program::dis [IP: 0083] ####
    #### testfinal.Program::sdCard_SDCardMounted [IP: 0039] ####
    #### Gadgeteer.Modules.GHIElectronics.SDCard::OnSDCardMountedEvent [IP: 003f] ####
    #### System.Reflection.MethodBase::Invoke [IP: 0000] ####
    #### Gadgeteer.Program::DoOperation [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
    #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
    #### Gadgeteer.Program::Run [IP: 0020] ####
A first chance exception of type 'System.IO.IOException' occurred in Microsoft.SPOT.IO.dll
Error invoking method "Gadgeteer.Modules.GHIElectronics.SDCard" (check arguments to Program.BeginInvoke are correct)


I have no idea why this is happening because it works for certain files but gives this error for other files. The same program was used to test all files. It just doesnt make sense why this error would appear. Please help me someone??

Hi Damien,
can you tell us anything about the files that fail? Are they in any way special? If you just read one that works and then one that fails, does the second one always fail? And if you reverse the order, does the first one still fail?? The error message to me implies it’s a general file IO error, can you read the files from a PC instead? What about if you put the files on a USB stick, can you read them there?

i have sorted the problem out. Its extremely silly. It reads from one sd card, but doesnt read from the other sd card and they were both formatted with the correct fat file system. So was just my luck i think. but atleast im able to read the files now. Thanks for the help tho.