Netduino plus 2 SD卡写入
Netduino plus 2自带SD卡槽,最大支持2G卡,以下是最基本的磁卡写入代码。
for (int i = 0; i < 50; i++) { using (var filestream = new FileStream(@"SD\OBDlog.txt", FileMode.Append)) { StreamWriter streamWriter = new StreamWriter(filestream); streamWriter.WriteLine(i.ToString()+"-\nThis is a test...\nThis is only a test...\n"); streamWriter.Flush(); streamWriter.Close(); streamWriter.Dispose(); Thread.Sleep(100); } } Thread.Sleep(5000); Debug.Print("Read File..."); //Test reading from file just written using (var filestream = new FileStream(@"SD\OBDlog.txt", FileMode.Open)) { StreamReader reader = new StreamReader(filestream); Debug.Print(reader.ReadToEnd()); reader.Close(); reader.Dispose(); }