You might want to look into serialization.
When you are offline, you want to serialize these "error logs" onto disk. Here are some extensions to serialize the data.
public static void Serialize(this object o, string fileName)
{
Stream stream = File.Open(fileName, FileMode.Create);
var serializer = new BinaryFormatter();
serializer.Serialize(stream, o);
stream.Close();
}
public static T Deserialize<T>(string fileName)
{
T objectToDeSerialize;
using (Stream stream = File.Open(fileName, FileMode.Open))
{
var serializer = new BinaryFormatter();
objectToDeSerialize = (T) serializer.Deserialize(stream);
stream.Close();
}
return objectToDeSerialize;
}
So you would have a Serializable class representing your "errors".
[Serializable]
public class Error
{
public string Log { get; set; }
// other properties...
public Error(string log)
{
Log = log;
}
}
Now all you need to do is write the errors to some file when you need to store the offline errors.
Error offlineError = new Error("Internet is not connected.");
offlineError.Serialize("inetError.err");
To read back the error for when you do become online again, just use this.
Error error = SerializableHelper.Deserialize<Error>("inetError.err");
enjoy.