Hi guys,
I’m pretty new to this and got stuck with this simple thing that i can’t figure it out.
I want to log the temperature value for example in a text file. I can read and write the file on the .NET Gadgeteer program but when I open the file on my computer the information is not human understandable
For example “Hello SD card” gets stored as “OSJ÷«`zÓ«zc.ƒ” …
I need to read the file on the computer because I’m using the data to plot a graph.
I’m using the Fez Spider mainboard.
This is the Program.cs file:
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using System.Text;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Gadgeteer.Modules.Seeed;
using System.IO;
namespace HomeSensorize
{
public partial class Program
{
void ProgramStarted()
{
sdCard.SDCardMounted += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
}
void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
{
string rootDirectory = sdCard.GetStorageDevice().RootDirectory;
StreamWriter textFile = new StreamWriter(rootDirectory + @ "\hello.txt", true);
textFile.WriteLine("Hello SD card");
textFile.Close();
FileStream fileStream = new FileStream(rootDirectory + @ "\hello.txt", FileMode.Open);
byte[] data = new byte[fileStream.Length];
fileStream.Read(data, 0, data.Length);
fileStream.Close();
string text = new string(Encoding.UTF8.GetChars(data));
Debug.Print(text);
}
}
}
Also, where could I get some extra information on the alternative ways of writing data to the file system ?
Thanks