Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108

    [OpenSource] Proper Downloader

    Note: Downloaders are restricted on MPGH. Therefore, don't use them in the programs you release!

    I decided to release a small opensource project for a proper downloader.

    The whole project is included.

    [PHP]'This code is fully self-written.
    '(c) Blubb1337
    'Enjoy

    Imports System.IO
    Imports System.Text
    Imports System.Net

    'Since a lot of people seem to need a proper downloader, I decided 2 release a PROPER updater
    'Most updater use my.network.downloadfile, however this does not show progress and it generally sucks!
    'This updater uses a webclient. Using a webclient, you can display the current progress, the received bytes
    'and the total bytes to receive.

    'You also have a download completed event.

    'How to use this?
    'This is really easy, the only thing you need to change -> 4 Variables
    'links
    'Private Const _version As String = "http:/version.txt"
    'Private Const _FileToDL As String = "http:/Recorder.exe"
    'Private Const _log As String = "https://changelog.txt"
    'name
    'Private Const _Name As String = "Recorder"

    'I think this is pretty self-explanatory. You sure don't need to have a log, you can just take it out.

    'Furthermore, this updater uses multithread to check the newest version/load the checklog.
    'Usually the program executes one sub/function/action after another. With multithreads you can run
    'different subs/functions or whatever at the same time!
    'You may also change the prioritys of the multithreads

    'If you want to unpack a file after it has been downloaded, you can go for the sharpziplibrary:
    'https://www.mpgh.net/forum/33-visual-basics/126996-tutorial-unzipping-vb-net.html

    'Sub ExtractZip(ByVal FileToUnzip As String, ByVal WhereToSave As String, Optional ByVal Password As String = "")
    'Dim fz As New FastZip
    ' fz.Password = Password
    ' fz.ExtractZip(FileToUnzip, WhereToSave, "")
    ' End Sub

    Public Class Form1

    #Region "Declarations"
    'new webclient to for downloading
    WithEvents webC As New Net.WebClient

    Private apppath As String = Application.StartupPath & "\"
    Private filename As String

    'avoid the same filename twice
    Private i As Integer = 1

    'received/total bytes
    Private total, current As Integer

    'links
    Private Const _version As String = "https://version.txt"
    Private Const _FileToDL As String = "https://Recorder.exe"
    Private Const _log As String = "https://changelog.txt"

    'name
    Private Const _Name As String = "Recorder"

    'get a pages source code
    Private Function loadPage(ByVal page As String)
    Dim req As WebRequest = WebRequest.Create(page)
    Dim resp As WebResponse = req.GetResponse()

    Dim s As Stream = resp.GetResponseStream()
    Dim sr As StreamReader = New StreamReader(s, Encoding.ASCII)
    Dim doc As String = sr.ReadToEnd()
    Return doc
    End Function

    #End Region

    #Region "Download/Progress"

    Private Sub cmdDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDownload.Click
    If cmdDownload.Text = "Download" Then
    'start backgroundworker
    bgwDownload.RunWorkerAsync()
    Else
    'start the program
    Process.Start(filename)
    'end this application
    Application.Exit()
    End If
    End Sub

    Private Sub webC_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles webC.DownloadFileCompleted
    ' MsgBox("Download complete." & vbNewLine & vbNewLine _
    ' & "Saved at: " & filename)

    cmdDownload.Text = "Start " & _Name
    cmdDownload.Enabled = True
    End Sub

    Private Sub webC_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles webC.DownloadProgressChanged
    current = e.BytesReceived 'bytes it dled already
    total = e.TotalBytesToReceive 'total bytes it has to dl

    If total <> current Then 'if they are not the same
    cmdDownload.Enabled = False
    End If

    pbProgress.Value = e.ProgressPercentage 'show the procent percentage
    'pbProgress.Text = CInt(current / 1024) & "/" & CInt(total / 1024) & " KB received | " & e.ProgressPercentage & " %"
    lblprogress.Text = CInt(current / 1024) & "/" & CInt(total / 1024) & " KB received | " & e.ProgressPercentage & " %"
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwDownload.DoWork
    'start downloading the file
    webC.DownloadFileAsync(New Uri(_FileToDL), filename)
    End Sub

    #End Region

    #Region "Startup"

    Private Sub UpdateApp_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'to avoid threadovertaking actions -> program would just end
    Control.CheckForIllegalCrossThreadCalls = False

    'multithread so multiple things can be done at the same time -> load changelog
    Dim cl As New Threading.Thread(AddressOf changelog)
    cl.Priority = Threading.ThreadPriority.Highest
    cl.Start()

    'show the current version of the application
    lblCurV.Text &= Application.ProductVersion

    'to not replace the old version
    Do While IO.File.Exists(apppath & _Name & "_Updated - " & i & ".exe")
    i += 1
    Loop

    filename = apppath & _Name & "_Updated - " & i & ".exe"
    End Sub

    Private Sub changelog()
    txtChangeLog.Text = loadPage(_log)
    End Sub

    Private Sub newversion()
    lblNewV.Text &= loadPage(_version)
    End Sub

    Private Sub UpdateApp_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    Dim checkv As New Threading.Thread(AddressOf newversion)
    checkv.Priority = Threading.ThreadPriority.Highest
    checkv.Start()
    End Sub

    #End Region
    End Class
    [/PHP]

    Virus Scans:

    Updater for MPGH.rar - Jotti&#039;s malware scan

    VirusTotal - Free Online Virus, Malware and URL Scanner

    Have fun copy & pasters!



  2. The Following 11 Users Say Thank You to Blubb1337 For This Useful Post:

    .Celtics (08-21-2010),aLcohoL_95 (08-21-2010),b7bassam (07-25-2015),House (09-28-2010),Lolland (08-21-2010),matthieu503 (05-04-2012),mnpeepno2 (08-21-2010),NextGen1 (08-21-2010),skiiiz (08-21-2010),Terell. (08-21-2010),Tony Stark` (02-09-2011)

  3. #2
    aLcohoL_95's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    SatyRicon
    Posts
    685
    Reputation
    8
    Thanks
    291
    My Mood
    Cynical
    gj
    thanx for sharing it with us

    CANNIBAL CORPSE P0WNS


  4. #3
    Terell.'s Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    JAMAICAA
    Posts
    6,923
    Reputation
    273
    Thanks
    1,163
    My Mood
    Angry
    Thanks I may use this in the future

    Warrock Minion 8-13-2011 - N/A
    A.V.A Minion since 11-1-11 - 11-12-11

  5. #4
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Looks good, keep it up

  6. #5
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81
    its so big!!! ill rather use system.network.downloadfile...


    -----------------------------------------------

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  7. #6
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Good Job. Keep it up..!

  8. #7
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Quote Originally Posted by mnpeepno2 View Post
    its so big!!! ill rather use system.network.downloadfile...
    That's the point I am releasing it. Finally a proper downloader with progress ffs.



  9. #8
    Icøn's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Chiraq
    Posts
    448
    Reputation
    14
    Thanks
    1,088
    My Mood
    Twisted
    Looks good , Thanks

  10. The Following 3 Users Say Thank You to Icøn For This Useful Post:

    3l3menter (08-22-2010),banned1111 (08-25-2010),Vectorzz™ (08-22-2010)

  11. #9
    aLcohoL_95's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    SatyRicon
    Posts
    685
    Reputation
    8
    Thanks
    291
    My Mood
    Cynical
    Quote Originally Posted by Icøn View Post
    Looks good , Thanks
    do NOT say it
    DO IT!

    CANNIBAL CORPSE P0WNS


  12. The Following User Says Thank You to aLcohoL_95 For This Useful Post:

    Blubb1337 (08-21-2010)

  13. #10
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Added to tuts

    Great job Kevin.

  14. The Following User Says Thank You to Lolland For This Useful Post:

    Blubb1337 (08-21-2010)

  15. #11
    .Celtics's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    148
    Reputation
    10
    Thanks
    5
    My Mood
    Crappy
    Thanks!

    But I have a question,
    If I have an update of the app, what should I change, the version.txt?

    Last edited by .Celtics; 08-21-2010 at 10:25 AM.

  16. #12
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by .Celtics View Post
    Thanks!

    But I have a question,
    If I have an update of the app, what should I change, the version.txt?

    Yes, you need to change the version.txt.
    So, you can check the version using:

    Code:
    If Application.ProductVersion < CheckedVersion (version.txt) Then
    Msgbox ("Update available !!")
    End If
    
    Simple

  17. #13
    .Celtics's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    148
    Reputation
    10
    Thanks
    5
    My Mood
    Crappy
    About the " Private Const _FileToDL As String = "https://Recorder.exe""

    Im confused there , ill give an example

    For Example
    I released something, so at the 1st release, what will I put there? Since I dont have the link for the updated one?

  18. #14
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by .Celtics View Post
    About the " Private Const _FileToDL As String = "https://Recorder.exe""

    Im confused there , ill give an example

    For Example
    I released something, so at the 1st release, what will I put there? Since I dont have the link for the updated one?
    Well you could get a FTP and have a static new version.exe link and then simply delete the old one and re-upload a newer version so it has the same link. OR you could make the program read a .txt document, similar how you check the version via the internet but get the link from there.

    i.e (using Blubb's loadpage function)

    [php]
    Private Function loadPage(ByVal page As String)
    Dim req As WebRequest = WebRequest.Create(page)
    Dim resp As WebResponse = req.GetResponse()

    Dim s As Stream = resp.GetResponseStream()
    Dim sr As StreamReader = New StreamReader(s, Encoding.ASCII)
    Dim doc As String = sr.ReadToEnd()
    Return doc
    End Function
    [/php]

    Then just do

    [php]
    Dim LinkToDownloadFrom As String = LoadPage("https://www.yourftp.com/getlatestversionlink.txt")
    [/php]

    And that will tell your program where to download the latest version.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  19. The Following User Says Thank You to Jason For This Useful Post:

    .Celtics (08-21-2010)

  20. #15
    .Celtics's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    148
    Reputation
    10
    Thanks
    5
    My Mood
    Crappy
    Thanks! I get it naw

    Very last question,

    How do you make the progress bar have a text? Can find it in the properties

    Sorry for being a pain-in-the-ass
    Last edited by .Celtics; 08-21-2010 at 03:16 PM.

Page 1 of 2 12 LastLast

Similar Threads

  1. GunZ hacks (download)
    By Brunogol in forum Gunz General
    Replies: 23
    Last Post: 06-09-2007, 10:38 PM
  2. DOWNLOAD WoW.exe HERE! (Full Client For MPGH Server)
    By RebornAce in forum General Gaming
    Replies: 25
    Last Post: 05-14-2006, 02:54 AM
  3. Download Section
    By blahblahz in forum Suggestions, Requests & General Help
    Replies: 14
    Last Post: 02-08-2006, 09:14 AM
  4. Download And Signup For Warrock Korean
    By Paolo1993 in forum WarRock - International Hacks
    Replies: 66
    Last Post: 02-04-2006, 09:56 PM
  5. Juno Reactor 4TWoot (Downloads, 4TWoot)
    By Gulanzon in forum Entertainment
    Replies: 3
    Last Post: 01-23-2006, 08:26 AM