lmu
1
hi
I’d like to store a string array on an SD card(using FEZ Raptor & SD Card)
But my text file is always empty. (SD Card isn’t locked)
Can anyone help me?
StringBuilder sdata = new StringBuilder();
foreach (var s in data)
{
sdata.Append(s);
sdata.Append("\n");
}
byte[] bdata = Encoding.UTF8.GetBytes(sdata.ToString());
FileStream fileHandle = new FileStream(path, FileMode.Create);
fileHandle.Write(bdata, 0, data.Length);
fileHandle.Close();
RoSchmi
2
Hi,
shouldn’t it be:
fileHandle.Write(bdata, 0, bdata.Length);
if this does not help I would try to append something like the following code after filehandle.Close();
VolumeInfo[] vi = VolumeInfo.GetVolumes();
for (int i = 0; i < vi.Length; i++)
vi[i].FlushAll();
Kind regards
RoSchmi
Edit:
https://www.ghielectronics.com/community/forum/topic?id=19972
2 Likes
lmu
3
@ RoSchmi - Thanks for the reply
it was the bdata.length
thanks for the help