I just want to create an application where the user click on the "check for Update" button,
My application start to check update.
Uptill this I hav done so.
I use this Code for this:

        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("pastebin link")
        Dim response As System.Net.HttpWebResponse = request.GetResponse()

        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

        Dim newestversion As String = sr.ReadToEnd
        Dim currentversion As String = Application.ProductVersion

        If newestversion.Contains(currentversion) Then
            MsgBox("Application is up to date:" & vbNewLine & "Latest Version :  --" & vbNewLine & "Current Version :  --", MsgBoxStyle.Information, "Update Msg.")
        Else
            MsgBox("Update available," & vbNewLine & "Visit to our website to download newer version", MsgBoxStyle.Information, "Update msg")
        End If

now this compare the Characters, If Differnce found Update available else not...
But If I add the link on my pastebin on 3rd line, and then is this possible that my updater app just check the first line.
And if update available then:
msg("update found," & vbnewline & "Want to Download?",vbmsgboxstyle.yesno,"msg")
If yes then start download from the link paste on 3rd line of same link.

I wanna try this but when I add the 3rd line it's says that Update available even though not so Please help me with this.
Please

Dani AI

Generated

Quick, practical fix and a safer pattern to follow (builds on original idea and suggestion):

The reason the simple substring check was failing is that Contains (or similar string tests) is brittle — "1.0.0.1" is contained inside "1.0.0.10", whitespace/BOM can hide the real value, and HTML wrappers (Pastebin normal view) will corrupt the plain-text layout. Use a tiny plain-text manifest (plain text, raw URL) where line 1 is the version and line 3 is the direct download URL, parse the manifest as lines, trim BOM/whitespace, and compare numeric versions with System.Version rather than by substring. Validate the URL (absolute, http/https) and only download from trusted HTTPS sources. Save the file to a temp location, show progress or prompt, then start the installer with a ProcessStartInfo.

Example (VB.NET, .NET 4.5+ — uses HttpClient and an async download task). This reads the first and third lines, parses them, compares versions, and downloads if confirmed:

' .NET 4.5+ example: line1 = version, line3 = download URL (use raw paste link)
Imports System.Net.Http
Imports System.IO

Private Async Function CheckForUpdateAsync() As Task
    Dim client As New HttpClient()
    Dim raw As String = Await client.GetStringAsync("https://pastebin.com/raw/ID")
    raw = raw.Replace(ChrW(&HFEFF), "") ' strip BOM
    Dim lines = raw.Split(New String() {vbCrLf, vbLf}, StringSplitOptions.RemoveEmptyEntries)
    If lines.Length < 3 Then Return

    Dim remoteVerStr = lines(0).Trim()
    Dim downloadUrl = lines(2).Trim()
    Dim remoteVer As Version = Nothing
    Dim currentVer As New Version(Application.ProductVersion)

    If Version.TryParse(remoteVerStr, remoteVer) AndAlso remoteVer > currentVer Then
        If MessageBox.Show("New version " & remoteVer & " available. Download now?", "Update", MessageBoxButtons.YesNo) = DialogResult.Yes Then
            Dim tempFile = Path.Combine(Path.GetTempPath(), Path.GetFileName(New Uri(downloadUrl).LocalPath))
            Using wc As New System.Net.WebClient()
                Await wc.DownloadFileTaskAsync(New Uri(downloadUrl), tempFile)
            End Using
            Dim pi As New ProcessStartInfo(tempFile) With {.UseShellExecute = True}
            Process.Start(pi)
        End If
    End If
End Function

Troubleshooting and hardening notes: use the raw paste URL (not the HTML page), handle network exceptions, show download progress (WebClient events), verify file size or checksum before running, require HTTPS and a trusted host, and prefer signed installers. If targeting older .NET, use WebClient.DownloadString instead of HttpClient.

Recommended Answers

All 3 Replies

let me tell this in short:
I want to know How can I make the application that can read onlinme text file?
and seperate lines.

if you want to read online text file as for updater...
then I will like to say you that you can update your application with the link specifies in the text document...
As you are creating your application so obviously you are going to type the text in text document (version) so From now you can do this:L
give a specific title as update version to your text document.
on the First Line type your version and on the last line (i.e. 2) type the Download Link. (just direct download link)

now what you have to do changes in your app is Instead of watching/Reading version online let the app should download the text document... (as the text documet having only version and link so size of this file will be 1kb or 2kb max) so your file will downlaod soon...

Then After let the application run the File... (create new form invisible)
add two textbox. :- the first will work as for version and the secondly will work as for download location...

type the code on form_Load event:

Dim i as String
i = my.application.info.version
dim m as DialogResult
m = Msgbox("Like to update your application?",msgboxstyle.yesno,"Update")

'now 1st of all your application will check whether the textbox1.text = version or not:

if textbox1.text <> i then
 if m.msgboxresult.yes then
     process.start(textbox2.text)
 Else
     'do nothing
 end if

if you having the question that how you can read the first and last line of textbox then the code is here:

Dim lines() As String = IO.File.ReadAllLines(my.aplication.info.directorypath & "\textfile.txt")
TextBox1.Text = lines(0)
TextBox2.Text = lines(lines.Length - 1)

@Deep Modi:
Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.