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

SD Memory issue when writing

sd memory netduino plus two

  • Please log in to reply
1 reply to this topic

#1 cSharper

cSharper

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationOrlando, FL

Posted 23 July 2015 - 04:19 PM

Hey all,

 

So I have an issue that has been causing my head to spin when writing to an SD card. I have searched all the threads and couldn't find anything like my issue.

I can read perfectly fine from the SD card, but when writing, it will only write over text that is currently in the file.

            string FilePath = @"\SD\yourfile.txt";

            using (var fs = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 512))
            using (var sw = new StreamWriter(fs)) {
                sw.WriteLine("Will This String Write?");
                Thread.Sleep(1000);
                sw.WriteLine("done.");
                Thread.Sleep(1000);
                sw.Flush();
            }
            Debug.Print("We did something");

So for example if my text file contains the string "My String" then when I run the above program, the only thing in the text file will be "Will This" instead of the entire string. And if there is nothing in the file at all, then nothing is written. I have the lastest firmware and SDK's. In fact I recently just reinstalled everything. I am also using a 2GB sd card as recommended.

 

Thanks for your help!



#2 cSharper

cSharper

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationOrlando, FL

Posted 31 July 2015 - 06:46 PM

FYI: I finally figured out the answer after days of trial and error:

VolumeInfo.GetVolumes()[0].FlushAll();

Yup that's all you have to do. Not sure why it works







Also tagged with one or more of these keywords: sd, memory, netduino, plus, two

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.