Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually I created a ftp web page which can download, upload, delete.
This is the code for downloading a particular file from ftp server:
Dim myFtpWebRequest As FtpWebRequest
Dim myFtpWebResponse As FtpWebResponse
Dim myStreamWriter As StreamWriter

myFtpWebRequest =WebRequest.Create("ftp:/ftp page/filename.ext")
myFtpWebRequest.Credentials = New NetworkCredential("username","Password")
myFtpWebRequest.Method = WebRequestMethods.Ftp.DownloadFile
myFtpWebRequest.UseBinary = True
myFtpWebResponse = myFtpWebRequest.GetResponse()
myStreamWriter = New StreamWriter(Server.MapPath(filename.ext))
myStreamWriter.Write(New StreamReader(myFtpWebResponse.GetResponseStream()).ReadToEnd)
litResponse.Text = myFtpWebResponse.StatusDescription

This code is working perfect and I can download. But it is downloading the particular file into the web page folder which I created now.
Example: C:\Documents and Settings\Sadhish\My Documents\Visual Studio 2008\WebSites\WebSite4

How can I download a particular file in desktop or C drive.
Example C:/file/downloadfiles

Thanks in advances.
Updated 17-Nov-10 0:29am
Sandeep Mewara 17-Nov-10 6:29am    
Use PRE tags to format your code part. It makes the question readable.

1 solution

You hardly have to change a thing. Change this line:

myStreamWriter = New StreamWriter(Server.MapPath(filename.ext))


myStreamWriter = New StreamWriter("C:\file\downloadfiles\filename.ext")

further reading:


hope it helps
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900