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.

sfx's Content

There have been 52 items by sfx (Search limited from 13-May 23)


By content type

See this member's


Sort by                Order  

#60232 .NET Micro Framework V4.3 SDK-R2-Beta

Posted by sfx on 26 September 2014 - 01:02 AM in General Discussion

Hi Chris,

 

I've done as you said and everything seems to be working well now. Thanks for your help!

 

Nathan




#60330 SD Card Write issue

Posted by sfx on 03 October 2014 - 12:08 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Dizel,

 

The full .NET Framework will ensure that a FileStream object is disposed of by any wrapper objects that get created (e.g. StreamWriter etc). Because of this, it isn't necessary to call dispose (via a using statement) on a wrapped FileStream since the wrapper will do it for you. Of course, in the interests of readability and consistency it is good practice to always explicitly declare your intentions on a FileStream with either a using statement or a try/finally block. However, I'm not sure if NETMF behaves the same way as its big brother on this.

 

At any rate, it appears that instead of your StreamWriter instance wrapping your FileStream object both are wrapping the shared file path. This indicates to me you have two Stream derived objects competing for the same resource at the same time.

 

Try this:

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

Take care,

 

Nathan





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.