vendredi 16 février 2018

Random choice (application name to download) [VB.NET]

Im using this code for download the application (console-application):

If Not File.Exists(s & "\Example.rar") Then
      My.Computer.Network.DownloadFile("link", s & "\Example1")
Else
      MsgBox("This File Already Exist!", MsgBoxStyle.Critical, "Error")
End If

Even if the code is wrong I would do something like that:

    Sub GenerateName()
        Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        Dim r As New Random
        Dim sb As New StringBuilder
        For i As Integer = 1 To 6
           Dim idx As Integer = r.Next(0, 35)
           sb.Append(s.Substring(idx, 1))
        Next
        ....
   End Sub

If Not File.Exists(s & "\" & Sb) Then
      My.Computer.Network.DownloadFile("DownloadLink", s & Sb)
Else
      MsgBox("This File Already Exist!", MsgBoxStyle.Critical, "Error")
End If

if someone knows how to return the value of sb (if I'm not mistaken), by downloading the file with that name. Thanks




Aucun commentaire:

Enregistrer un commentaire