'm new to the systems. NET and especially C #, I come from the small world of Arduino, but this system is too limited for my applications.,
So I turned to Cerbuino. Everything works correctly except little close … SDCARD … Unable to read or write, I can open and close files on the SD card but I’m trying to read a line of text I still get an exception Io.IoException
private void lecture_data()
{
GHI.OSHW.Hardware.StorageDev.MountSD();
if (VolumeInfo.GetVolumes()[0].IsFormatted)
{
_root = VolumeInfo.GetVolumes()[0].RootDirectory;
string fic = Path.Combine(_root, "config.txt");
if (File.Exists(fic))
{
try
{
using (StreamReader reader = new StreamReader(fic))
{
Eco_on = Int32.Parse(reader.ReadLine());
Eco_off = Int32.Parse(reader.ReadLine());
for (int i = 0; i < 6; i++)
capteur[i] = Int32.Parse(reader.ReadLine());
}
}
catch (Exception e)
{
Debug.Print("Exception :");
Debug.Print(e.Message);
}
}
}
}
What’s wrong on my code?? i’m lost …
PS : Sorry for my English I’m French … ceci explique cela…
This writes a Guid to a file on the Bee every 5 seconds...and I even tested it to make sure it works
using System;
using System.IO;
using Microsoft.SPOT.IO;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
namespace SD_Test
{
public partial class Program
{
private GT.Timer _timer;
private string _root;
void ProgramStarted()
{
GHI.OSHW.Hardware.StorageDev.MountSD();
if (VolumeInfo.GetVolumes()[0].IsFormatted)
{
_root = VolumeInfo.GetVolumes()[0].RootDirectory;
_timer = new GT.Timer(5000);
_timer.Tick += new GT.Timer.TickEventHandler(TimerTick);
_timer.Start();
}
}
void TimerTick(GT.Timer timer)
{
string fileName = Path.Combine(_root, "file.txt");
Stream stream;
if(File.Exists(fileName))
{
stream = File.OpenWrite(fileName);
stream.Position = stream.Length;
}
else
{
stream = File.Create(fileName);
}
using(var writer = new StreamWriter(stream))
{
writer.WriteLine(Guid.NewGuid().ToString());
}
stream.Dispose();
}
}
}
Your question is missing one or more of these details:[ul]
The name of the product.
The code you’re trying to run.
Details on your setup.[/ul]
(Generated by QuickReply)