منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : مشروع تحميل ملفات من الانترنت
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
رأيت برنامج شبيه هنا ولكن الاختلاف لا يضر يفيد في الاطلاع




لمحة عن الكود

PHP كود :
Private WithEvents downloader As New FileDownloader 


PHP كود :
' A simple implementation of setting the directory path, 
adding files from a textbox and starting the download
Private Sub btnStart_Click(ByVal sender As System.Object_
    ByVal e 
As System.EventArgsHandles btnStart.Click
    Dim openFolderDialog 
As New FolderBrowserDialog
    With downloader
        If openFolderDialog
.ShowDialog() = Windows.Forms.DialogResult.OK Then
            
.Files.Clear()
 
           .LocalDirectory openFolderDialog.SelectedPath
            For Each path 
As String In txtFilesToDownload.Lines
           
' The FileInfo structure will parse your path, 
      ' 
and split it to the path itself and the file name
     
 ' which will both be available for you
                .Files.Add(New FileDownloader.FileInfo(path))
            Next
            .Start()
        End If
    End With
End Sub 


PHP كود :
Private Sub btnPauze_Click(ByVal sender As System.Object_
        ByVal e 
As System.EventArgsHandles btnPauze.Click
    
' Pause the downloader
    downloader.Pause()
End Sub 

PHP كود :
Private Sub btnResume_Click(ByVal sender As System.Object_
        ByVal e 
As System.EventArgsHandles btnResume.Click
    
' Resume the downloader
    downloader.Resume()
End Sub 

PHP كود :
Private Sub btnStop_Click(ByVal sender As System.Object_
        ByVal e 
As System.EventArgsHandles btnStop.Click
    
' Stop the downloader
    ' 
NoteThis will not be instantaneous the current requests need to 
    
' be closed down, and the downloaded files need to be deleted
    downloader.Stop()
End Sub 


PHP كود :
' This event is fired every time the paused or busy state is changed, 
and used here to set the controls of the interface
Private 
Sub downloader_StateChanged() _
    Handles downloader
.StateChanged 'This is equal to: Handles 
                       '
downloader.IsBusyChangeddownloader.IsPausedChanged
    
' Setting the buttons
    btnStart.Enabled = downloader.CanStart
    btnStop.Enabled = downloader.CanStop
    btnPauze.Enabled = downloader.CanPause
    btnResume.Enabled = downloader.CanResume

    ' 
Enabling or disabling the setting controls
    txtFilesToDownload
.ReadOnly downloader.IsBusy
    cbUseProgress
.Enabled Not downloader.IsBusy
End Sub 

PHP كود :
' Occurs every time a block of data has been downloaded, 
and can be used to display the progress with
' Note that you can also create a timer, and display the progress 
every certain interval
' Also note that the progress properties return a size in bytes, 
which is not really user friendly to display
' The FileDownloader class provides shared functions to format these 
byte amounts to a more readable formateither in binary or decimal notation
Private Sub downloader_ProgressChanged() Handles downloader.ProgressChanged
    pBarFileProgress
.Value CInt(downloader.CurrentFilePercentage)
 
   lblFileProgressDetails.Text String.Format("Downloaded {0} of {1} ({2}%)"_
        FileDownloader
.FormatSizeBinary(downloader.CurrentFileProgress), _
        FileDownloader
.FormatSizeBinary(downloader.CurrentFileSize), _
        downloader
.CurrentFilePercentage) & String.Format(" - {0}/s"_
        FileDownloader
.FormatSizeBinary(downloader.DownloadSpeed))
 
   If downloader.SupportsProgress Then
        pBarTotalProgress
.Value CInt(downloader.TotalPercentage)
 
       lblTotalProgressDetails.Text _
        String
.Format("Downloaded {0} of {1} ({2}%)"_
        FileDownloader
.FormatSizeBinary(downloader.TotalProgress), _
        FileDownloader
.FormatSizeBinary(downloader.TotalSize), _
        downloader
.TotalPercentage)
 
   End If
End Sub 
جزاك الله خيرا وبارك فيك أخي الفاضل