Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:52:34+00:00 2026-06-13T12:52:34+00:00

I’m trying to convert a C# script that i had found on another site:

  • 0

I’m trying to convert a C# script that i had found on another site: http://www.codeproject.com/Tips/307548/Resume-Suppoert-Downloading

So far i have managed to convert most of it but once i run the program it creates a file of only 0 bytes. When ran in C# it works perfectly so i know its got to be a problem with my convertion skills (or lack of in this case).

This the the C#

        static void DownloadFile(string sSourceURL, string sDestinationPath)
    {
        long iFileSize = 0;
        int iBufferSize = 1024;
        iBufferSize *= 1000;
        long iExistLen = 0;
        System.IO.FileStream saveFileStream;
        if (System.IO.File.Exists(sDestinationPath))
        {
            System.IO.FileInfo fINfo =
               new System.IO.FileInfo(sDestinationPath);
            iExistLen = fINfo.Length;
        }

        if (iExistLen > 0)
            saveFileStream = new System.IO.FileStream(sDestinationPath,
              System.IO.FileMode.Append, System.IO.FileAccess.Write,
              System.IO.FileShare.ReadWrite);
        else
            saveFileStream = new System.IO.FileStream(sDestinationPath,
              System.IO.FileMode.Create, System.IO.FileAccess.Write,
              System.IO.FileShare.ReadWrite);

        System.Net.HttpWebRequest hwRq;
        System.Net.HttpWebResponse hwRes;
        hwRq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(sSourceURL);
        hwRq.AddRange((int)iExistLen);
        System.IO.Stream smRespStream;
        hwRes = (System.Net.HttpWebResponse)hwRq.GetResponse();
        smRespStream = hwRes.GetResponseStream();

        iFileSize = hwRes.ContentLength;

        int iByteSize;
        byte[] downBuffer = new byte[iBufferSize];

        while ((iByteSize = smRespStream.Read(downBuffer, 0, downBuffer.Length)) > 0)
        {
            saveFileStream.Write(downBuffer, 0, iByteSize);
        }
    } 

Now my VB.NET

        Dim sSourceURL As String = TextBox1.Text
    Dim sDestinationPath As String = TextBox2.Text

    Dim iFileSize As Long = 0
    Dim iBufferSize As Integer = 1024
    iBufferSize *= 1000
    Dim iExistLen As Long = 0
    Dim saveFileStream As System.IO.FileStream

    If System.IO.File.Exists(sDestinationPath) Then
        Dim fINfo As New System.IO.FileInfo(sDestinationPath)
        iExistLen = fINfo.Length
    End If

    If iExistLen > 0 Then
        saveFileStream = New System.IO.FileStream(sDestinationPath, System.IO.FileMode.Append, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)
    Else
        saveFileStream = New System.IO.FileStream(sDestinationPath, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)
    End If

    Dim hwRq As System.Net.HttpWebRequest
    Dim hwRes As System.Net.HttpWebResponse
    hwRq = DirectCast(System.Net.HttpWebRequest.Create(sSourceURL), System.Net.HttpWebRequest)
    hwRq.AddRange(CInt(iExistLen))
    Dim smRespStream As System.IO.Stream
    hwRes = DirectCast(hwRq.GetResponse(), System.Net.HttpWebResponse)
    smRespStream = hwRes.GetResponseStream()

    iFileSize = hwRes.ContentLength

    Dim iByteSize As Integer
    Dim downBuffer As Byte() = New Byte(iBufferSize) {}

    While ((smRespStream.Read(downBuffer, 0, downBuffer.Length))) > 0
        saveFileStream.Write(downBuffer, 0, iByteSize)
    End While

I believe that the issues that i am experiencing are in this piece of code:

    While ((smRespStream.Read(downBuffer, 0, downBuffer.Length))) > 0
        saveFileStream.Write(downBuffer, 0, iByteSize)
    End While

Thanks all for your time 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:52:35+00:00Added an answer on June 13, 2026 at 12:52 pm

    I think your missing an assignment to iByteSize which is what is being checked as being greater than 0.

    So something like this:

    While (iByteSize = (smRespStream.Read(downBuffer, 0, downBuffer.Length))) > 0
       saveFileStream.Write(downBuffer, 0, iByteSize)
    End While
    

    EDIT: Something like this perhaps but I haven’t tested it locally!

    iByteSize = (smRespStream.Read(downBuffer, 0, downBuffer.Length))
    While (iByteSize > 0)
       saveFileStream.Write(downBuffer, 0, iByteSize)
       iByteSize = (smRespStream.Read(downBuffer, 0, downBuffer.Length))
    End While
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.