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

  • SEARCH
  • Home
  • 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 6736041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:05:00+00:00 2026-05-26T11:05:00+00:00

Translating a subroutine from VB6 to VB2005. It downloads a single text file via

  • 0

Translating a subroutine from VB6 to VB2005. It downloads a single text file via FTP from an internal company server. Ive use this code in VB6 for many years and have not had to provide proxy credentials to get past the corporate firewall, only the credentials to get into the FTP server.

hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
hconnection = InternetConnect(hOpen, HostURL, INTERNET_INVALID_PORT_NUMBER, user, PW, INTERNET_SERVICE_FTP, nFlag, 0)
DownloadFile = FtpGetFile(hconnection, File$, TargetPathFile$, False, INTERNET_FLAG_RELOAD, FTP_TRANSFER_TYPE_ASCII, 0)

In VB2005 I use

        Dim reqFTP As FtpWebRequest = Nothing
        Dim ftpStream As Stream = Nothing

        Dim outPathAndFile As String = My.Computer.FileSystem.CombinePath(TargetPath, HostFileName)
        Dim outputStream As New FileStream(outPathAndFile, FileMode.Create)
        reqFTP = DirectCast(FtpWebRequest.Create(New Uri("ftp://" + HostURL + "/" + HostFileName)), FtpWebRequest)
        reqFTP.Method = WebRequestMethods.Ftp.DownloadFile
        reqFTP.UseBinary = False 'True if binary file, False if ASCII text file
        reqFTP.Credentials = New NetworkCredential(id, pw)
        Dim response As FtpWebResponse = DirectCast(reqFTP.GetResponse(), FtpWebResponse)
        ftpStream = response.GetResponseStream()
        Dim cl As Long = response.ContentLength
        Dim bufferSize As Integer = 2048
        Dim readCount As Integer
        Dim buffer As Byte() = New Byte(bufferSize - 1) {}

        readCount = ftpStream.Read(buffer, 0, bufferSize)
        While readCount > 0
            outputStream.Write(buffer, 0, readCount)
            readCount = ftpStream.Read(buffer, 0, bufferSize)
        End While

It errors out on the reqFTP.GetResponse with “The remote server returned an error. (407) Proxy authentication required”. I just cant figure out why in my old code I never had to provide a proxy server and in the new code it seems like it requires it. I tried a manual connection via WS_FTP and it does not require a proxy so I must be doing something wrong but cant figure out what.

  • 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-05-26T11:05:01+00:00Added an answer on May 26, 2026 at 11:05 am

    Ok in the interim I did some more research and found two things. One if I added that I need no proxy as follows reqFTP.Proxy = Nothing ‘no proxy to get out of the corporate firewall since the server is internal that resolves my proxy problem. Once the proxy was resolved I had another issue with downloading from a mainframe which in the end my path and dataset name has to be in the form [code]ftpSite//’test.file2′[\code]. Once I did those two things it works like a charm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble translating a subroutine from Perl to PHP (I'm new to Perl).
Over here I asked about translating an ASM file to C, and from the
I am translating text files from one set of definitions to another, and I
Someone help in translating the following text from image, it's Chinese. alt text
I am translating SQL Server SQL Statements into their ANSI generic equivalent at present,
I'm currently translating an API from C# to Java which has a network component.
currently I'm translating an app from C# into ActionScript (Silverlight to Flex) and I
I am reading in CSV file and translating it to an SQL Table. The
I'm translating a piece of code from javascript to coffeescript. for (var i =
I'm translating an API from C to C#, and one of the functions allocates

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.