/// <summary> /// This method serialize an ArrayList to a byte[] and save it in a file /// </summary> /// <param name="pbList">The ArrayList we want to save</param> public void SaveCards(ArrayList pbList) { if (!_sdCard.IsCardMounted) // If the SDCard isn't mounted { _sdCard.Mount(); // Mount the file system } do { Debug.Print("Veuillez attendre que la carte soit montée"); } while (!_sdCard.IsCardMounted); // We wait that the SD card is correctly mounted try { string sdPath = VolumeInfo.GetVolumes()[0].RootDirectory; // Get the path to the storage FileStream writer = new FileStream(sdPath + @"\" + FILE_NAME, FileMode.Create, FileAccess.Write); if (pbList is ArrayList) { byte[] SerializedData = Reflection.Serialize(pbList, typeof(ArrayList)); writer.Write(SerializedData, 0, SerializedData.Length); } writer.Close(); } catch (Exception e) { Debug.Print(e.ToString()); } if (_sdCard.IsCardMounted) // If the card is mounted { _sdCard.Unmount(); // Unmount the card } }