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.

Dizel

Member Since 27 Sep 2014
Offline Last Active Dec 16 2014 06:47 PM
-----

Topics I've Started

SD Card Write issue

02 October 2014 - 12:19 PM

Hello guys,

I have problem with SD card, when i read from it all fine, but when i try write i have Exception in System.IO

DirectoryInfo dir = new DirectoryInfo(@"\SD\");
bool dirExist = dir.Exists;
var files = dir.GetFiles();
string fileName = @"\SD\test.txt.txt";
string fileWrite = @"\SD\testWrite.txt";
bool fileExist = File.Exists(fileName);
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
using (FileStream file = 
    new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))

//using (FileStream file=
    new FileStream(fileWrite, FileMode.OpenOrCreate, FileAccess.ReadWrite))
//using(StreamWriter wr = new StreamWriter(fileWrite))
//{
//    wr.WriteLine("Hello");
//    wr.WriteLine("StreamWriter");
//}

using (StreamReader reader = new StreamReader(file))
{
    string line;
    while ((line = reader.ReadLine()) != null)
    {
        led.Write(true);
        Thread.Sleep(250);
        led.Write(false);
        Thread.Sleep(250);
     }
}

Exception raised in commented code

 

Can some one help me?


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.