Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

somaia

Member Since 26 May 2012
Offline Last Active Nov 24 2012 09:35 PM
-----

#36983 read file from SD

Posted by somaia on 10 October 2012 - 07:34 PM

Hello I have netduino board.I interfaced 4G SD card with it.I had saved file in the SD card then I tried to read it line by line.Each line I read I write it in a new file.The program is working normally but after reading some lines this error appear "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.IO.dll". This is my program can anyone help me please. using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; using System.IO; using SecretLabs.NETMF.IO; using System.Text; namespace NetduinoApplication1 { public class Program { public static void Main() { // write your code here StorageDevice.MountSD("SD", SPI_Devices.SPI1, Pins.GPIO_PIN_D10); string line; // line that will read from the pliantext FileStream aa = new FileStream("SD\\enc_f.txt", FileMode.Create, FileAccess.Write, FileShare.None); StreamWriter enc_plain = new StreamWriter(aa); FileStream sr = new FileStream("SD\\text.txt", FileMode.Open);//, FileAccess.Read,FileShare.None); StreamReader r = new StreamReader(sr); int c = 0; while ((line = r.ReadLine()) != null) { line = r.ReadLine(); enc_plain.WriteLine(line); c++; } aa.Close(); enc_plain.Close(); sr.Close(); r.Close();


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.