Hello.
I am trying to download a file which is on an FTP Server.
Lets say I own Website A and Website B. In Site A in a folder named foobar I have a file named download.aspx and in that file I want to have code that downloads a file in Website B called lorem.txt
I want the file to be saved into the foobar directory in Website A.
Is this possible?
So far, my code seems to download (as the contents of the file I download is displayed) but there is no sign of the file. Where does it go?
The code "works" but the file does not get copied/downloaded, where is the file being downloaded to?
I am trying to download a file which is on an FTP Server.
Lets say I own Website A and Website B. In Site A in a folder named foobar I have a file named download.aspx and in that file I want to have code that downloads a file in Website B called lorem.txt
I want the file to be saved into the foobar directory in Website A.
Is this possible?
So far, my code seems to download (as the contents of the file I download is displayed) but there is no sign of the file. Where does it go?
VB.NET:
Public Sub ftpDownload(ByVal filePath As String, ByVal fileName As String)
Dim reqFTP As FtpWebRequest
Try
Dim file As String = (filePath + fileName)
Dim request As FtpWebRequest = CType(WebRequest.Create(file),FtpWebRequest)
request.Method = WebRequestMethods.Ftp.DownloadFile
request.Credentials = New NetworkCredential("user", "pass")
Dim response As FtpWebResponse = CType(request.GetResponse,FtpWebResponse)
Dim ftpStream As Stream = response.GetResponseStream
Dim reader As StreamReader = New StreamReader(ftpStream, System.Text.Encoding.UTF8)
output.Text = reader.ReadToEnd
output.Text = (output.Text + "Download Complete")
Catch ex As Exception
output.Text = ("Error: " + ex.ToString)
End Try
End Sub
The code "works" but the file does not get copied/downloaded, where is the file being downloaded to?
Last edited by a moderator: