60 lines
2.0 KiB
VB.net
60 lines
2.0 KiB
VB.net
Imports System.Data.SqlClient
|
|
|
|
Public Class Update
|
|
Public sAppPath As String = Application.StartupPath
|
|
|
|
Public Updatequelle As String = "\\share01.verag.ost.dmn\Programme\Doku\"
|
|
|
|
Private Sub Update_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
TxtInfo.Text = "Programmpfad: " & sAppPath & vbCrLf
|
|
End Sub
|
|
|
|
Private Function Test_Pfade(Source As String)
|
|
If Not System.IO.Directory.Exists(Source) Then
|
|
TxtInfo.Text &= "Updatequelle nicht verfügbar!" & vbCrLf
|
|
Else
|
|
TxtInfo.Text = ""
|
|
TxtInfo.Text &= "Updatequelle gefunden, starte Update..." & vbCrLf
|
|
Return True
|
|
End If
|
|
End Function
|
|
|
|
Private Sub CmdUpdate_Click(sender As Object, e As EventArgs) Handles CmdUpdate.Click
|
|
If CmdUpdate.Text = "Fertig" Then
|
|
Process.Start("Dokumentation.exe")
|
|
Me.Close()
|
|
End If
|
|
If Test_Pfade(Updatequelle) = True Then
|
|
CmdUpdate.Enabled = False
|
|
UpdateStart()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function UpdateStart()
|
|
|
|
For Each p In System.Diagnostics.Process.GetProcessesByName("Dokumentation.exe")
|
|
p.Kill()
|
|
Next
|
|
Try
|
|
My.Computer.FileSystem.DeleteFile(sAppPath & "\" & "Dokumentation.exe")
|
|
Catch ex As Exception
|
|
MsgBox("Löschen fehlgeschlagen: " & ex.Message)
|
|
'TxtInfo.Text &= ex.Message
|
|
End Try
|
|
|
|
Dim files As String() = IO.Directory.GetFiles(Updatequelle)
|
|
For Each file As String In files
|
|
Try
|
|
TxtInfo.Text &= "Kopiere " & System.IO.Path.GetFileName(file) & vbCrLf
|
|
My.Computer.FileSystem.CopyFile(file, sAppPath & "\" & System.IO.Path.GetFileName(file), True)
|
|
Catch ex As Exception
|
|
' TxtInfo.Text &= "... Datei übersprungen:" & vbCrLf & ex.Message
|
|
End Try
|
|
Next
|
|
CmdUpdate.Enabled = True
|
|
CmdUpdate.Text = "Fertig"
|
|
End Function
|
|
|
|
|
|
End Class
|