Reputation: 14285
i have got a remote machine which i can access using ftp (it has static ip with userid and pass). i am able to send file to that location using FTP through asp.net but don't know how to get that file back using asp.net through code. actually wants 2 things using asp.net code: 1. get file from remote machine which has static ip and userid & pass. 2. after getting that file delete that file from remote machine.
please provide me solution Thanks
Upvotes: 0
Views: 1421
Reputation: 14285
Finally i got the solution:
Protected Sub btnDownloadFile_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim myFtpWebRequest As FtpWebRequest
Dim myFtpWebResponse As FtpWebResponse
Dim myStreamWriter As StreamWriter
myFtpWebRequest = WebRequest.Create("ftp://ftp_server_name/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)
myStreamWriter.Close()
litResponse.Text = myFtpWebResponse.StatusDescription
myFtpWebResponse.Close()
End Sub
http://dotnetacademy.blogspot.com/2010/12/how-to-upload-download-delete-file.html
Upvotes: 0
Reputation: 51
Check out this page.
http://bytes.com/topic/visual-basic-net/answers/349767-retrieve-file-ftp-address
Upvotes: 1