Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

My.Computer.Network.DownloadFile and KeepAlive in VB.NET

Posted on 2009-07-14
2
Medium Priority
?
1,581 Views
Last Modified: 2012-05-07
I have an issue with downloading a file using FTP where I have to use KeepAlive = false otherwise I get an exception:

System.Net.WebException:"The remote server returned an error: (503) Bad sequence of commands"

Is there a way to set KeepAlive = false using the method My.Computer.Network.DownloadFile ?
0
Comment
Question by:jes12345
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 1200 total points
ID: 24849303
You'll probably need to use a WebClient object, and set a header....

        Dim wc As New Net.WebClient
        wc.Headers.Set(Net.HttpRequestHeader.Connection, "Keep-Alive")
        wc.DownloadFile("ftp path", "save path")

Wayne
0
 

Accepted Solution

by:
jes12345 earned 0 total points
ID: 24849431
Thanks for the advise-will the code above set Keep-Alive to false?

Also I have found a workaround myself using System.Net.FtpWebRequest. Using this I can set the following:
Dim request As FtpWebRequest = DirectCast(WebRequest.Create(target), FtpWebRequest)
request.KeepAlive = False

However I am not quite sure what I am doing here on the first line - can you advise about this? (DirectCast etc)

Also do you know what are the difference between WebClient, WebRequest and FtpWebRequest?
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question