Gets the newer version if available and within the checking
frequency.
Namespace: CleanCode.IOAssembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
public string GetNewerVersion(
int days,
DateTime lastChecked
)
Public Function GetNewerVersion ( _
days As Integer, _
lastChecked As DateTime _
) As String
public:
String^ GetNewerVersion(
int days,
DateTime lastChecked
)
Parameters
- days
- Type: System Int32
The frequency to check, in days. Zero indicates
to always check.
- lastChecked
- Type: System DateTime
The last checked date.
Return Value
Newer version number or null.
Similar to
RemindNewerVersion(Int32, DateTime), this checks for
the presence of a newer release, returning that release number
for the calling code to handle.
Here is an example detailing the use of this method:
UpdateCheck updateCheck = new UpdateCheck(
Assembly.GetExecutingAssembly(), REPOSITORY, PROG_PATTERN);
DateTime lastUpdateCheck = Properties.Settings.Default.UpdateChecked;
string newVer =
updateCheck.GetNewerVersion(UPDATE_REMINDER_FREQUENCY, lastUpdateCheck);
if (newVer != null)
{
MessageBox.Show(
"newer version " + newVer + " available -- please upgrade");
Properties.Settings.Default.UpdateChecked = DateTime.Now.Date;
}
UpdateCheck updateCheck = new UpdateCheck(
Assembly.GetExecutingAssembly(), REPOSITORY, PROG_PATTERN);
DateTime lastUpdateCheck = Properties.Settings.Default.UpdateChecked;
string newVer =
updateCheck.GetNewerVersion(UPDATE_REMINDER_FREQUENCY, lastUpdateCheck);
if (newVer != null)
{
MessageBox.Show(
"newer version " + newVer + " available -- please upgrade");
Properties.Settings.Default.UpdateChecked = DateTime.Now.Date;
}
This sample illustrates a use case where the calling program wishes
to notify the user every 2 days, rather than every time the
application is launched. The last time checked is stored
in a user's persistent settings.