- Duefectu likes this
- Netduino Forums
- → Viewing Profile: Likes: somaia
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.
Community Stats
- Group Members
- Active Posts 4
- Profile Views 4809
- Member Title New Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
1
Neutral
User Tools
Friends
somaia hasn't added any friends yet.
#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();
- Netduino Forums
- → Viewing Profile: Likes: somaia
- Privacy Policy