Downloading Zip File from FTP Site

  • Thread starter Thread starter Hugh McLaughlin
  • Start date Start date
H

Hugh McLaughlin

Hello everyone and thanks for your help in advance. I am
working on an application that allows a user to downlad a
zip file from an FTP site. I have used the following
code:

Dim URL As String = "f= "ftp://ftpsite/data.zip"

Dim outputFile As String = "C:\Data.zip"
Dim wReq As WebRequest
Dim wResp As WebResponse
Dim respStream As Stream
Dim reader As StreamReader
Dim writer As StreamWriter

' create the Web Request
wReq = WebRequest.Create(URL)

' get the response
wResp = wReq.GetResponse()
respStream = wResp.GetResponseStream()
reader = New StreamReader(respStream,
Encoding.ASCII)

' and write it to the required file
writer = New StreamWriter(outputFile)
writer.Write(reader.ReadToEnd())

However, the application fails to work. I have verified
that the FTP site is configured properly and works, so
the problem is in my code. I am not exactly sure what is
wrong. Any help would be greatly appreciated. Thanks.
 
Hello Hugh,

Please refer to http://www.codeproject.com/csharp/ftpdriver1.asp for a FTP client sample on how to download a file from
FTP server. Thanks.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Hugh McLaughlin" <[email protected]>
!Sender: "Hugh McLaughlin" <[email protected]>
!Subject: Downloading Zip File from FTP Site
!Date: Sat, 19 Jul 2003 13:29:45 -0700
!Lines: 31
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNONH3F+g2D7qZDRKGEHrgrhHLGfQ==
!Newsgroups: microsoft.public.dotnet.general
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:101833
!NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
!X-Tomcat-NG: microsoft.public.dotnet.general
!
!Hello everyone and thanks for your help in advance. I am
!working on an application that allows a user to downlad a
!zip file from an FTP site. I have used the following
!code:
!
!Dim URL As String = "f= "ftp://ftpsite/data.zip"
!
! Dim outputFile As String = "C:\Data.zip"
! Dim wReq As WebRequest
! Dim wResp As WebResponse
! Dim respStream As Stream
! Dim reader As StreamReader
! Dim writer As StreamWriter
!
! ' create the Web Request
! wReq = WebRequest.Create(URL)
!
! ' get the response
! wResp = wReq.GetResponse()
! respStream = wResp.GetResponseStream()
! reader = New StreamReader(respStream,
!Encoding.ASCII)
!
! ' and write it to the required file
! writer = New StreamWriter(outputFile)
! writer.Write(reader.ReadToEnd())
!
!However, the application fails to work. I have verified
!that the FTP site is configured properly and works, so
!the problem is in my code. I am not exactly sure what is
!wrong. Any help would be greatly appreciated. Thanks.
!
 
Back
Top