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.
Photo

Writing to SD card


  • Please log in to reply
2 replies to this topic

#1 newfierich

newfierich

    Member

  • Members
  • PipPip
  • 15 posts

Posted 10 May 2011 - 02:02 PM

I am trying to write to a SD card on my netduino. My code creates a File, but does not write to it... Here is my code from main: public static void Main() { SerialPort port1 = new SerialPort("COM1", 57600, Parity.None, 8, StopBits.One); port1.Open(); SerialPort Port2 = new SerialPort("COM2", 115200, Parity.None, 8, StopBits.One); Port2.Open(); OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); FileStream fs = new FileStream("\\SD\\test.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 512); StreamWriter sw = new StreamWriter(fs); sw.WriteLine("Hello World"); while (true) { } }

#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 10 May 2011 - 06:59 PM

I am trying to write to a SD card on my netduino. My code creates a File, but does not write to it...

You must call sw.Close (either explicitly or as a part of using statement) to ensure that all data is written out to the underlying stream. For more details and sample code please have a look at the following topic.

#3 newfierich

newfierich

    Member

  • Members
  • PipPip
  • 15 posts

Posted 12 May 2011 - 04:46 PM

@CW2 Thanks for pointing me to the proper topic. I missed it while searching earlier




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.