Code Is Not Working .
-
Hi, I got a downloader program form internet but it was made in C# . I converted it to VB.NET . There is no errors in the code , but it isn't working !:doh: Here is the few code form the whole project which is not working:
Imports System.IO Imports System.Net Imports System.Text Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Windows.Forms Imports System.Threading Public Class Download Private thrDownload As Thread ' The stream of data retrieved from the web server Private strResponse As Stream ' The stream of data that we write to the harddrive Private strLocal As Stream ' The request to the web server for file information Private webRequest As HttpWebRequest ' The response from the web server containing information about the file Private webResponse As HttpWebResponse ' The progress of the download in percentage Private Shared PercentProgress As Integer ' The delegate which we will call from the thread to update the form Private Delegate Sub UpdateProgessCallback(ByVal BytesRead As Int64, ByVal TotalBytes As Int64) ' When to pause Private goPause As Boolean = False Private Sub Download(ByVal startPoint As Object) Try Dim startPointInt As Integer = Convert.ToInt32(startPoint) ' Create a request to the file we are downloading webRequest = DirectCast(Net.WebRequest.Create("http://dl.google.com/picasa/picasaweb-current-setup.exe"), HttpWebRequest) ' Set the starting point of the request webRequest.AddRange(startPointInt) ' Set default authentication for retrieving the file webRequest.Credentials = CredentialCache.DefaultCredentials ' Retrieve the response from the server webResponse = DirectCast(webRequest.GetResponse(), HttpWebResponse) ' Ask the server for the file size and store it Dim fileSize As Int64 = webResponse.ContentLength ' Open the URL for download strResponse = webResponse.GetResponseStream() ' Create a new file stream where we will be saving the data (local drive) If startPointInt = 0 Then strLocal = New FileStream("C:\", FileMode.Create, FileAccess.Write, FileShare.None) Else strLocal = New FileStream("C:\", FileMode.Append, FileAccess.Write, Fil
-
Hi, I got a downloader program form internet but it was made in C# . I converted it to VB.NET . There is no errors in the code , but it isn't working !:doh: Here is the few code form the whole project which is not working:
Imports System.IO Imports System.Net Imports System.Text Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Windows.Forms Imports System.Threading Public Class Download Private thrDownload As Thread ' The stream of data retrieved from the web server Private strResponse As Stream ' The stream of data that we write to the harddrive Private strLocal As Stream ' The request to the web server for file information Private webRequest As HttpWebRequest ' The response from the web server containing information about the file Private webResponse As HttpWebResponse ' The progress of the download in percentage Private Shared PercentProgress As Integer ' The delegate which we will call from the thread to update the form Private Delegate Sub UpdateProgessCallback(ByVal BytesRead As Int64, ByVal TotalBytes As Int64) ' When to pause Private goPause As Boolean = False Private Sub Download(ByVal startPoint As Object) Try Dim startPointInt As Integer = Convert.ToInt32(startPoint) ' Create a request to the file we are downloading webRequest = DirectCast(Net.WebRequest.Create("http://dl.google.com/picasa/picasaweb-current-setup.exe"), HttpWebRequest) ' Set the starting point of the request webRequest.AddRange(startPointInt) ' Set default authentication for retrieving the file webRequest.Credentials = CredentialCache.DefaultCredentials ' Retrieve the response from the server webResponse = DirectCast(webRequest.GetResponse(), HttpWebResponse) ' Ask the server for the file size and store it Dim fileSize As Int64 = webResponse.ContentLength ' Open the URL for download strResponse = webResponse.GetResponseStream() ' Create a new file stream where we will be saving the data (local drive) If startPointInt = 0 Then strLocal = New FileStream("C:\", FileMode.Create, FileAccess.Write, FileShare.None) Else strLocal = New FileStream("C:\", FileMode.Append, FileAccess.Write, Fil
-
Hi, I got a downloader program form internet but it was made in C# . I converted it to VB.NET . There is no errors in the code , but it isn't working !:doh: Here is the few code form the whole project which is not working:
Imports System.IO Imports System.Net Imports System.Text Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Windows.Forms Imports System.Threading Public Class Download Private thrDownload As Thread ' The stream of data retrieved from the web server Private strResponse As Stream ' The stream of data that we write to the harddrive Private strLocal As Stream ' The request to the web server for file information Private webRequest As HttpWebRequest ' The response from the web server containing information about the file Private webResponse As HttpWebResponse ' The progress of the download in percentage Private Shared PercentProgress As Integer ' The delegate which we will call from the thread to update the form Private Delegate Sub UpdateProgessCallback(ByVal BytesRead As Int64, ByVal TotalBytes As Int64) ' When to pause Private goPause As Boolean = False Private Sub Download(ByVal startPoint As Object) Try Dim startPointInt As Integer = Convert.ToInt32(startPoint) ' Create a request to the file we are downloading webRequest = DirectCast(Net.WebRequest.Create("http://dl.google.com/picasa/picasaweb-current-setup.exe"), HttpWebRequest) ' Set the starting point of the request webRequest.AddRange(startPointInt) ' Set default authentication for retrieving the file webRequest.Credentials = CredentialCache.DefaultCredentials ' Retrieve the response from the server webResponse = DirectCast(webRequest.GetResponse(), HttpWebResponse) ' Ask the server for the file size and store it Dim fileSize As Int64 = webResponse.ContentLength ' Open the URL for download strResponse = webResponse.GetResponseStream() ' Create a new file stream where we will be saving the data (local drive) If startPointInt = 0 Then strLocal = New FileStream("C:\", FileMode.Create, FileAccess.Write, FileShare.None) Else strLocal = New FileStream("C:\", FileMode.Append, FileAccess.Write, Fil
First, please use the <pre> tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read. Secondly, why are you converting the code? If the original project was written properly, you should be able to include the C# project in your solution or compile it separately and include the reference in your VB project to the DLL. There are already several file downloader components here on CP that I know will work with VB code in the manner I describe above. You can check out this one[^] as a start.
Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
-
First, please use the <pre> tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read. Secondly, why are you converting the code? If the original project was written properly, you should be able to include the C# project in your solution or compile it separately and include the reference in your VB project to the DLL. There are already several file downloader components here on CP that I know will work with VB code in the manner I describe above. You can check out this one[^] as a start.
Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
Scott Dorman wrote:
First, please use the "pre" tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read.
Sorry , I was my mistake .:-> You suggested the perfect suggestion. Thanks. :)
-
Scott Dorman wrote:
First, please use the "pre" tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read.
Sorry , I was my mistake .:-> You suggested the perfect suggestion. Thanks. :)
Dan`M wrote:
Sorry , I was my mistake
No problem. Just wanted to let you know for the future.
Dan`M wrote:
You suggested the perfect suggestion. Thanks.
You're welcome.
Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]