I am working on a windows phone app.
Just want to ask for some suggestion. Here is the problem:
I want to store a time in somewhere and use the time to check if I need an internal file update. (if my file has not been updated in 60 days, update it. something like this)
I am not sure if I can have access to the registry directly in the app. and the other possible way to solve the problem is maybe save the timestamp to a file in isolated storage. But I dont have a lot idea about how to save it in a easy to use format and how to read it again.
Any suggestions about saving timestamp?
Thank you
To save, just use a .ToString() on the date as you write it to isolated storage.
To revive it as a date, read it out as a string, then parse it using the DateTime class.
string inbounddate = OurHelperMethodReadStringFromIsolatedStorage();
DateTime newdate = DateTime.Parse( inbounddate );
An example is below. m_Helper is a utility class I have for reading and writing strings to isolated storage.
private void Button_GetTimeNow_Click(object sender, RoutedEventArgs e)
{
TextBlock_Now.Text = DateTime.Now.ToString();
}
private void Button_SaveTimeToISO_Click(object sender, RoutedEventArgs e)
{
m_Helper.WriteFile(TextBlock_Now.Text);
}
private void Button_GetTimeFromISO_Click(object sender, RoutedEventArgs e)
{
TextBlock_FromISO.Text = m_Helper.ReadFile();
DateTime _loaded = DateTime.Parse( TextBlock_FromISO.Text );
TextBlock_Output.Text = _loaded.ToLongDateString();
}