Start 2
This commit is contained in:
59
Dokumentation_Updater/Update.vb
Normal file
59
Dokumentation_Updater/Update.vb
Normal file
@@ -0,0 +1,59 @@
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Public Class Update
|
||||
Public sAppPath As String = Application.StartupPath
|
||||
|
||||
Public Updatequelle As String = "\\192.168.0.91\f\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
|
||||
Reference in New Issue
Block a user