Segui il video qui sotto per vedere come installare il nostro sito come web app sulla tua schermata principale.
Nota: Questa funzionalità potrebbe non essere disponibile in alcuni browser.
Pubblicità
ovvio che non va... l'utente lorigio ti ha consigliato di sostituire solo gli argomenti del metodo CreateText, in particolare penso che ti stia suggerendo di provare usando i backslash al posto degli slash.no, non va.
Using sw1 As StreamWriter =
Imports System.Net
Imports System
Imports System.IO
Public Class Form1
Dim link As String = "http://raitoteam.altervista.org/"
Dim sLine3 As String = ""
Dim sLine2 As String = ""
Dim arrText As New ArrayList()
Dim arrText2 As New ArrayList()
Private WithEvents downl As System.Net.WebClient
Private Sub Form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If My.Computer.FileSystem.FileExists("log.txt") Then
BackgroundWorker1.RunWorkerAsync()
Else
Using sw As StreamWriter = File.CreateText("log.txt")
sw.WriteLine("Inizio log.txt")
sw.Close()
End Using
BackgroundWorker1.RunWorkerAsync()
End If
End Sub
#Region "Md5 checker"
Public Function MD5CalcFile(ByVal filepath As String) As String
'If FileIniziale.Text = "" Then
'MsgBox("devi scegliere un file!")
'Else
filepath = "./pack/" & sLine3
' apre il file in sola lettura
Using reader As New System.IO.FileStream(filepath, IO.FileMode.Open, IO.FileAccess.Read)
Using md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
' hash contenuto in questo file
Dim hash() As Byte = md5.ComputeHash(reader)
' ritorno formattato in hex dell'hash
Return ByteArrayToString(hash)
End Using
End Using
End Function
' funzione per convertire un array di byte in una stringa esadecimale
Private Function ByteArrayToString(ByVal arrInput() As Byte) As String
Dim StringBuilder As New System.Text.StringBuilder(arrInput.Length * 2)
For i As Integer = 0 To arrInput.Length - 1
StringBuilder.Append(arrInput(i).ToString("X2"))
Next
Return StringBuilder.ToString().ToLower
End Function
#End Region
#Region "Initiate Download"
Private Sub InitiateDownload(ByVal remoteUrl As String, ByVal localFilePath As String)
'* qui
Me.ProgressBar1.Value = 0
If Me.downl Is Nothing Then
Me.downl = New Net.WebClient
End If
End Sub
Private Sub downl_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downl.DownloadProgressChanged
'Progress Bar
Me.ProgressBar1.Maximum = CInt(e.TotalBytesToReceive)
Me.ProgressBar1.Value = CInt(e.BytesReceived)
End Sub
Private Sub downl_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles downl.DownloadFileCompleted
'a download finito modifica il file di log
'..............................................................................
'data e ora per i log
Dim dt As DateTime
dt = DateTime.Now
' data e ora:
Dim dataOra As String = dt.ToString
' solo data in formato GG/MM/AAAA:
Dim data As String = dt.ToString("dd/MM/yyyy")
' solo ora in formato HH.MM.SS (ore da 0 a 23):
Dim ora As String = dt.ToString("T")
' stampa i tre valori:
Dim s As String = dataOra
'..............................................................................
Dim SW As StreamWriter
Dim b As String
b = My.Computer.FileSystem.ReadAllText("./log.txt")
SW = New StreamWriter("./log.txt", False, System.Text.UTF8Encoding.Default)
SW.Write(b & vbCrLf & s & vbCrLf & "Fisierul" & sLine3 & " Este acum OK!")
SW.Flush()
SW.Close()
End Sub
#End Region
#Region "Miscarea Programul-ui"
Dim NewPoint As New System.Drawing.Point
Dim X, Y As Integer
Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
X = Control.MousePosition.X - Me.Location.X
Y = Control.MousePosition.Y - Me.Location.Y
End Sub
Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
NewPoint = Control.MousePosition
NewPoint.X -= (X)
NewPoint.Y -= (Y)
Me.Location = NewPoint
End If
End Sub
#End Region
Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
If My.Computer.FileSystem.FileExists("log.txt") Then
Else
Using sw As StreamWriter = File.CreateText("log.txt")
sw.WriteLine("Start log.txt")
sw.Close()
End Using
End If
'..............................................................................
'data e ora per i log
Dim dt As DateTime
dt = DateTime.Now
' data e ora:
Dim dataOra As String = dt.ToString
' solo data in formato GG/MM/AAAA:
Dim data As String = dt.ToString("dd/MM/yyyy")
' solo ora in formato HH.MM.SS (ore da 0 a 23):
Dim ora As String = dt.ToString("T")
' stampa i tre valori:
Dim s As String = dataOra
'..............................................................................
Dim arrText As New ArrayList()
Dim st1 As System.IO.Stream
Dim sr1 As System.IO.StreamReader
Dim req1 As System.Net.WebRequest = _
System.Net.WebRequest.Create(link & "test.txt")
Dim resp1 As System.Net.WebResponse = _
req1.GetResponse
st1 = resp1.GetResponseStream
sr1 = New System.IO.StreamReader(st1)
Dim st2 As System.IO.Stream
Dim sr2 As System.IO.StreamReader
Dim req2 As System.Net.WebRequest = _
System.Net.WebRequest.Create(link & "md5.txt")
Dim resp2 As System.Net.WebResponse = _
req2.GetResponse
st2 = resp2.GetResponseStream
sr2 = New System.IO.StreamReader(st2)
'...............................................
Do
sLine2 = sr2.ReadLine()
sLine3 = sr1.ReadLine()
Dim SW As StreamWriter
Dim b As String
Label4.Text = "Connecting to server ..."
If Not sLine3 Is Nothing Then
ListBox1.Items.Add(sLine3)
ListBox2.Items.Add(sLine2)
If My.Computer.FileSystem.FileExists("./pack/" & sLine3) Then
Else
Using sw1 As StreamWriter = File.CreateText("./pack/" & sLine3)
sw1.WriteLine("This is my file.")
sw1.Close()
End Using
InitiateDownload(link & sLine3, "./pack/" & sLine3)
b = My.Computer.FileSystem.ReadAllText("./log.txt")
SW = New StreamWriter("./log.txt", False, System.Text.UTF8Encoding.Default)
SW.Write(b & vbCrLf & s & vbCrLf & "Fisierul" & sLine3 & "Nu este prezent, Descarcare incepe.")
SW.Flush()
SW.Close()
End If
ListBox3.Items.Add(sLine2)
Label4.Text = "Testare: " & sLine3 & " ..."
If MD5CalcFile(sLine3) = sLine2 Then
Label4.Text = "Fisierul " & sLine3 & "Este ok"
b = My.Computer.FileSystem.ReadAllText("./log.txt")
SW = New StreamWriter("./log.txt", False, System.Text.UTF8Encoding.Default)
SW.Write(b & vbCrLf & s & vbCrLf & sLine3 & " Este ok")
SW.Flush()
SW.Close()
Else
Label4.Text = "Fisierul " & sLine3 & "Nu este ok"
b = My.Computer.FileSystem.ReadAllText("./log.txt")
SW = New StreamWriter("./log.txt", False, System.Text.UTF8Encoding.Default)
SW.Write(b & vbCrLf & s & vbCrLf & sLine3 & " Nu este ok")
InitiateDownload(link & sLine3, "./pack/" & sLine3)
SW.Flush()
SW.Close()
b = My.Computer.FileSystem.ReadAllText("./log.txt")
SW = New StreamWriter("./log.txt", False, System.Text.UTF8Encoding.Default)
Label4.Text = "Il file " & sLine3 & " non è ok, sta venendo riscaricato!"
SW.Write(b & vbCrLf & s & vbCrLf & "il file" & sLine3 & " non è ok, sta venendo riscaricato!")
SW.Flush()
SW.Close()
End If
End If
Loop Until sLine3 Is Nothing
Label4.Text = "Ora puoi giocare ! ^^ "
End Sub
End Class