Visual Basic.NET - Descarga de archivos y Unzip

 
Vista:
Imágen de perfil de Lautaro
Val: 22
Ha aumentado su posición en 289 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Descarga de archivos y Unzip

Publicado por Lautaro (5 intervenciones) el 27/06/2020 23:32:20
Buenas tardes, les paso a comentar mi problema en cuestión. Hace mucho realicé una aplicación en visual basic 6, el cual ya se encuentra obsoleto en las computadoras nuevas, debido a esto mi juego utilizaba un programa hecho en este lenguaje, el cual bajaba los archivos nuevo y pasan por Unzip, para reemplazarlos.

El programa funcionaba bien a pesar de estar hecho en vb6, pero estoy teniendo un problema con windows defender y me borra la app. La página virustotal.com identifica 13 antivirus que marcan virus/troyano en la app hecha en vb6.

Aprendiendo un poco y probando distintas técnicas llegue a una aplicación similar a la que windows defender me borra, pero hecha esta vez en vb.net

Lo que tiene funcional el código que van a ver es:
- Accede a un .txt de una página web para comprobar la versión.
- Descarga de archivos .ZIP desde una página web.
- Descomprime los .zip. En caso de existir el archivo lo borra y lo descomprime nuevamente.

Ahora, virustotal.com me marca 6 antivirus, en vez de 13. Ahora estoy probando si windows defender me lo borra o lo deja, y también se lo pasé a varios usuarios.

Adjunto el código. Si alguno tiene experiencia en vbnet me gustaria que me diera algunos consejos sobre la programación que apliqué acá, ya que hice solo 3 apps en este lenguaje. También debido a que no se el codigo mas eficiente, me gustaria otras alternativas y comparar la velocidad con la que trabaja

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Imports System
Imports System.IO
Imports System.IO.Compression
Imports System.Net
 
 
Module General
 
    Private URL_WEB As String = "http://desteriumao.ucoz.es/"
    Private URL_WEB_PATCH As String = "PATCH/"
    Private URL_WEB_VERSION As String = "Update.txt"
 
    Private PATCH_NAME As String = "Parche"
    Private PATCH_EXTENSION As String = ".zip"
 
    Private Downloading As Boolean
 
    Private Function File_Version() As Integer
        Using FileRead As New System.IO.StreamReader(Application.StartupPath + "\INIT\Update.ini")
            Return Val(FileRead.ReadToEnd())
        End Using
    End Function
    Private Function File_Version_Web() As Integer
        Using Client As New WebClient()
            Return Val(Client.DownloadString(URL_WEB + URL_WEB_VERSION))
        End Using
    End Function
 
 
    Public Sub File_DownloadAndPatch()
 
        Dim FileVersion As Integer = File_Version()
        Dim FileVersionWeb As Integer = File_Version_Web()
        Dim Diference As Integer = FileVersionWeb - FileVersion
 
        If Diference <> 0 And FileVersionWeb > 0 Then
            'frmMain.lblPatch.Text = "Descargando parches. Por favor espere y no cierre la aplicación."
            Downloading = True
 
            For A As Integer = (1 + FileVersion + A) To FileVersionWeb
                frmMain.lblPatch.Text = "Descargando " + PATCH_NAME + A.ToString + PATCH_EXTENSION
                frmMain.lblPatch.Refresh()
                File_Download(A)
 
                frmMain.lblPatch.Text = "Instalando " + PATCH_NAME + A.ToString + PATCH_EXTENSION
                frmMain.lblPatch.Refresh()
                File_Unzip(A)
            Next
 
            frmMain.lblPatch.Text = "Actualización finalizada."
            Dim ID As Integer = Shell(Application.StartupPath + "\Desterium.exe", AppWinStyle.NormalFocus)
            Application.Exit()
        Else
            Downloading = False
            frmMain.lblPatch.Text = "El juego se encuentra actualizado."
 
            Dim ID As Integer = Shell(Application.StartupPath + "\Desterium.exe", AppWinStyle.NormalFocus)
        End If
 
        Exit Sub
    End Sub
 
    Private Sub File_Download(ByVal PatchNum As Integer)
 
        Dim FileName As String = PATCH_NAME + PatchNum.ToString + PATCH_EXTENSION
        Dim UserName As String = "..."
        Dim Password As String = "..."
 
        Using client As New WebClient()
            client.Credentials = New NetworkCredential(UserName, Password)
            client.DownloadFile(URL_WEB + URL_WEB_PATCH + FileName, FileName)
        End Using
    End Sub
 
    Private Sub File_Unzip(ByVal FileNum As Integer)
        Dim zipPath As String = ".\" + PATCH_NAME + FileNum.ToString + PATCH_EXTENSION
 
        Dim extractPath As String = Application.StartupPath
        extractPath = Path.GetFullPath(extractPath)
        If Not extractPath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) Then extractPath += Path.DirectorySeparatorChar
 
        Using archive As ZipArchive = ZipFile.OpenRead(zipPath)
 
            For Each entry As ZipArchiveEntry In archive.Entries
 
                If Not entry.FullName.EndsWith("/", StringComparison.OrdinalIgnoreCase) Then
                    Dim destinationPath As String = Path.GetFullPath(Path.Combine(extractPath, entry.FullName))
 
                    If File.Exists(destinationPath) Then
                        Call File.Delete(destinationPath)
                        If destinationPath.StartsWith(extractPath, StringComparison.Ordinal) Then entry.ExtractToFile(destinationPath)
                    Else
                        If destinationPath.StartsWith(extractPath, StringComparison.Ordinal) Then entry.ExtractToFile(destinationPath)
                    End If
 
                End If
            Next
        End Using
    End Sub
End Module
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder