Perform-an-update-using-previously-downloaded-files - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Perform an update using previously downloaded files
VB code
Dim WithEvents wodAppUpdate1 As wodAppUpdateCom
Private Sub Form_Load()
    Set wodAppUpdate1 = New wodAppUpdateCom

    'Using Check Method we will open our configuration file and check for update.
    wodAppUpdate1.Check "http://www.some_website.com/update.txt"
End Sub

'PrevDetected Event fires when component detects new files from previous run.
Private Sub wodAppUpdate1_PrevDetected()
    'If such new files are already downloaded from previous run. Inside PrevDetected you can decide what you want to do with those files.
    If MsgBox("Previous download detected. Update now?", vbYesNo + vbQuestion, "Update files..") = vbYes Then
        'Using Update Method you can update files without performing new check and new download because they are sufficient to replace and update your application.
        wodAppUpdate1.Update
    Else
        'Clear Method will delete any leftover files that were downloaded from the server and new download will start again from beginning.
        wodAppUpdate1.Clear
    End If
End Sub

'CheckDone Event fires when component has finished checking for new updates.
Private Sub wodAppUpdate1_CheckDone(ByVal NewFiles As Long, ByVal ErrorCode As Long, ByVal ErrorText As String)
    If ErrorCode = 0 Then
        If NewFiles Then
            If MsgBox("New files found. Download?", vbYesNo + vbQuestion, "New files found!") = vbYes Then
                'If new file (files) is found we can download it using Download Method.
                wodAppUpdate1.Download
            End If
        Else
            MsgBox "No new versions found. Your application is up-to-date."
        End If
    Else
        MsgBox "There was an error checking for updates: " & ErrorText
    End If
End Sub

'DownloadDone Event fires when component finishes downloading all files.
Private Sub wodAppUpdate1_DownloadDone(ByVal ErrorCode As Long, ByVal ErrorText As String)
    If ErrorCode = 0 Then
        If MsgBox("Download successful. Replace now?", vbYesNo + vbQuestion, "Replace files..") = vbYes Then
            'Finally when new file (files) is downloaded we can update it using Update Method.
            wodAppUpdate1.Update
        End If
    Else
        MsgBox "There was an error downloading: " & ErrorText
    End If
End Sub
VB.NET code
Dim WithEvents wodAppUpdate1 As WODAPPUPDATECOMLib.wodAppUpdateCom
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    wodAppUpdate1 = New WODAPPUPDATECOMLib.wodAppUpdateCom

    'Using Check Method we will open our configuration file and check for update.
    wodAppUpdate1.Check("http://www.some_website.com/update.txt")
End Sub

'PrevDetected Event fires when component detects new files from previous run.
Private Sub wodAppUpdate1_PrevDetected() Handles wodAppUpdate1.PrevDetected
    'If such new files are already downloaded from previous run. Inside PrevDetected you can decide what you want to do with those files.
    If MsgBox("Previous download detected. Update now?", vbYesNo + vbQuestion, "Update files..") = vbYes Then
        'Using Update Method you can update files without performing new check and new download because they are sufficient to replace and update your application.
        wodAppUpdate1.Update()
    Else
        'Clear method on the other side will delete any leftover files that were downloaded from the server and new download will start again from beginning.
        wodAppUpdate1.Clear()
    End If
End Sub

'CheckDone Event fires when component has finished checking for new updates.
Private Sub wodAppUpdate1_CheckDone(ByVal NewFiles As Integer, ByVal ErrorCode As Integer, ByVal ErrorText As String) Handles wodAppUpdate1.CheckDone
    If ErrorCode = 0 Then
        If NewFiles Then
            If MsgBox("New files found. Download?", vbYesNo + vbQuestion, "New files found!") = vbYes Then
                'If new file (files) is found we can download it using Download Method.
                wodAppUpdate1.Download()
            End If
        Else
            MsgBox("No new versions found. Your application is up-to-date.")
        End If
    Else
        MsgBox("There was an error checking for updates: " & ErrorText)
    End If
End Sub

'DownloadDone Event fires when component finishes downloading all files.
Private Sub wodAppUpdate1_DownloadDone(ByVal ErrorCode As Integer, ByVal ErrorText As String) Handles wodAppUpdate1.DownloadDone
    If ErrorCode = 0 Then
        If MsgBox("Download successful. Replace now?", vbYesNo + vbQuestion, "Replace files..") = vbYes Then
            'Finally when new file (files) is downloaded we can update it using Update Method.
            wodAppUpdate1.Update()
        End If
    Else
        MsgBox("There was an error downloading: " & ErrorText)
    End If
End Sub
C# code
WODAPPUPDATECOMLib.wodAppUpdateCom wodAppUpdate1;
private void Form1_Load(object sender, EventArgs e)
{
    wodAppUpdate1 = new WODAPPUPDATECOMLib.wodAppUpdateCom();
    wodAppUpdate1.CheckDone += new WODAPPUPDATECOMLib._IwodAppUpdateComEvents_CheckDoneEventHandler(wodAppUpdate1_CheckDone);
    wodAppUpdate1.DownloadDone += new WODAPPUPDATECOMLib._IwodAppUpdateComEvents_DownloadDoneEventHandler(wodAppUpdate1_DownloadDone);
    wodAppUpdate1.PrevDetected += new WODAPPUPDATECOMLib._IwodAppUpdateComEvents_PrevDetectedEventHandler(wodAppUpdate1_PrevDetected);

    //Using Check Method we will open our configuration file and check for update.
    wodAppUpdate1.Check("http://www.some_website.com/update.txt", null);
}

//PrevDetected Event fires when component detects new files from previous run.
void wodAppUpdate1_PrevDetected()
{
    //If such new files are already downloaded from previous run. Inside PrevDetected you can decide what you want to do with those files.
    System.Windows.Forms.DialogResult msgres = System.Windows.Forms.MessageBox.Show("Previous download detected. Update now?", "Update files?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    if (msgres == DialogResult.Yes)
        //Using Update Method you can update files without performing new check and new download because they are sufficient to replace and update your application.
        wodAppUpdate1.Update();
    else
        //Clear method on the other side will delete any leftover files that were downloaded from the server and new download will start again from beginning.
        wodAppUpdate1.Clear();
}

//CheckDone Event fires when component has finished checking for new updates.
void wodAppUpdate1_CheckDone(int NewFiles, int ErrorCode, string ErrorText)
{
    if (ErrorCode == 0)
    {
        if (NewFiles > 0)
        {
            DialogResult result = MessageBox.Show("New files found. Download?", "New files found!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                //If new file (files) is found we can download it using Download Method.
                wodAppUpdate1.Download();
            }
        }
        else
        {
            MessageBox.Show("No new versions found. Your application is up-to-date.");
        }
    }
    else
    {
        MessageBox.Show("There was an error checking for updates: " + ErrorText);
    }
}

//DownloadDone Event fires when component finishes downloading all files.
void wodAppUpdate1_DownloadDone(int ErrorCode, string ErrorText)
{
    if (ErrorCode == 0)
    {
        DialogResult resultUpd = MessageBox.Show("Download successful. Replace now?", "Replace files..", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

        if (resultUpd == DialogResult.Yes)
        {
            //Finally when new file (files) is downloaded we can update it using Update Method.
            wodAppUpdate1.Update();
        }
    }
    else
    {
        MessageBox.Show("There was an error downloading: " + ErrorText);
    }
}