I want to name my file after the current time in miliseconds since 1970.
At the moment I just have a counter and increment it after every new file. But when the app restarts the counter goes back to zero and I overwrite the files when I start saving them again.
So I was thinking if I just use the time in seconds or miliseconds then I wont have this problem.
So my question is how to I get the time in miliseconds on windows mobile.
This is what I am currently doing to generate my file names.
string fileName = savedCounter + ".jpg";
You can use Ticks
A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.
DateTime unixEpoch = new DateTime(1970, 1, 1);
DateTime currentDate = DateTime.Now;
long totalMiliSecond = (currentDate.Ticks - unixEpoch.Ticks) /10000;
Console.WriteLine(totalMiliSecond);
string fileName = string.Concat(totalMiliSecond,".jpg");
Console.WriteLine(fileName);