تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
بعض الأسئلة
#1
السلام عليكم اخواني
كيفكم ان شاء الله تمام ,

اخواني لدي بعض الأسئلة
كيفية تنزيل ملف Txt من الأنترنت و قرائت محتواه
------
كيفية جعل البرنامج ينزل ملف تنفيذي و يقوم با تشغيله ؟

و بارك الله فيكم ,
الرد }}}}
تم الشكر بواسطة:
#2
dr.salah كتب :السلام عليكم اخواني
كيفكم ان شاء الله تمام ,

اخواني لدي بعض الأسئلة
كيفية تنزيل ملف Txt من الأنترنت و قرائت محتواه
------
كيفية جعل البرنامج ينزل ملف تنفيذي و يقوم با تشغيله ؟

و بارك الله فيكم ,
كيف تنزيل ملف اليك هذا المثال
كود :
Imports System.Net
Public Class Form1
    Private WithEvents httpclient As WebClient
    Dim StartTime As Date = Nothing
    Dim Speed As Double = 0

#Region " ClientAreaMove Handling "
    Const WM_NCHITTEST As Integer = &H84
    Const HTCLIENT As Integer = &H1
    Const HTCAPTION As Integer = &H2
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case m.Msg
            Case WM_NCHITTEST
                MyBase.WndProc(m)
                If m.Result = HTCLIENT Then m.Result = HTCAPTION
            Case Else
                MyBase.WndProc(m)
        End Select
    End Sub
#End Region


    Dim Mymessagebox

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        httpclient = New WebClient
        Dim download As String = TextBox1.Text
        Dim save As String = TextBox2.Text
        httpclient.DownloadFileAsync(New Uri(download), save)
        Label2CurrentStat.Text = "CurrentStatus: Download..."
        StartTime = Now
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SaveFileDialog1.ShowDialog()
        TextBox2.Text = SaveFileDialog1.FileName
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ProgressBar1.Style = ProgressBarStyle.Blocks
        Label2CurrentStat.Text = "CurrentStatus:"
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Mymessagebox = MsgBox("Are you sure you want to Pause the program if Pause you can't Resme Download?", MsgBoxStyle.YesNo, "")
        If Mymessagebox = MsgBoxResult.Yes Then
            MsgBox("The program is now going to Pause", MsgBoxStyle.Critical, "")
            httpclient.CancelAsync()
        Else
            MsgBox("The Action Has Been Canceled", MsgBoxStyle.Exclamation, "")

        End If
    End Sub
    Private Sub httpclient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
        ProgressBar1.Maximum = e.TotalBytesToReceive
        ProgressBar1.Value = e.BytesReceived
        Label3.Text = "" & e.BytesReceived & "0.00MB of 1.00 GB"
        If e.ProgressPercentage = 100 Then
            Label2CurrentStat.Text = "CurrentStatus: Finished!"
            Process.Start(TextBox2.Text)
        End If

        Dim T As TimeSpan = (Now - StartTime)
        If T.TotalSeconds <> 0 Then
            Speed = CDbl(e.BytesReceived) / T.TotalSeconds
        End If

        Dim Mis As Integer = (e.TotalBytesToReceive - e.BytesReceived)
        T = TimeSpan.FromSeconds(Mis / Speed)
        Dim H, M, S As Integer
        Dim Left As String
        S = T.TotalSeconds
        Do While S > 60
            S -= 60
            M += 1
        Loop
        Do While M > 60
            M -= 60
            H += 1
        Loop
        If M = 0 Then
            Left = S & " sec"
        ElseIf H = 0 Then
            Left = M & " min " & S & " sec"
        Else
            Left = H & " h " & M & " min " & S & " sec"
        End If
        If S < 0 Then Left = "Calculating..."

        Label3.Text = "Download : " & e.ProgressPercentage & "%      " & "Speed : " & ConvertByte(Speed) & "/s      Left : " & Left & "      Downloaded : " & ConvertByte(e.BytesReceived) & " of " & ConvertByte(e.TotalBytesToReceive)

    End Sub

    Public Function ConvertByte(ByVal Length As Integer) As String
        Dim Str As String = ""
        If Length < 1024 Then
            Str = Length & " Byte"
        ElseIf Length < 1024000 Then
            Str = Math.Round((Length / 1024), 2) & " KB"
        ElseIf Length < 1024000000 Then
            Str = Math.Round((Length / 1048576), 2) & " MB"
        Else
            Str = Math.Round((Length / 1073741824), 2) & " GB"
        End If
        Return Str
    End Function
End Class

يمكنك بى استعمال هذا الكود ات تقرء ملفات text من النت مباشر
كود :
Dim web As New WebClient
        TextBox1.Text = web.DownloadString("http://YourWebSite.com/Text.txt")
الرد }}}}
تم الشكر بواسطة:


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم