The code below operates under windwos but not Linux file is created, but it is empty.
I think that the bug is in 'Credentials' because I can download files on server without authentication(Login/Password). Sorry for my English I am french Sub dl(ByVal remoteFile As String, ByVal localFile As String, ByVal username As String, ByVal password As String) '1. Create a request: must be in ftp://hostname format, ' not just ftp.myhost.com Dim URI As String = remoteFile Dim ftp As System.Net.FtpWebRequest = CType(FtpWebRequest.Create(URI), FtpWebRequest) '3. Settings and action ftp.KeepAlive = False 'we want a binary transfer, not textual data ftp.UseBinary = True 'Define the action required (in this case, download a file) ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile '2. Set credentials if not (username = "" andalso password = "") then ftp.Credentials = New NetworkCredential( username, password) end if '4. If we were using a method that uploads data e.g. UploadFile ' we would open the ftp.GetRequestStream here an send the data '5. Get the response to the Ftp request and the associated stream Using response As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse) Using responseStream As IO.Stream = response.GetResponseStream 'loop to read & write to file Using fs As New IO.FileStream(localFile, IO.FileMode.Create) Dim buffer(2047) As Byte Dim read As Integer = 0 Do read = responseStream.Read(buffer, 0, buffer.Length) fs.Write(buffer, 0, read) Loop Until read = 0 'see Note(1) responseStream.Close() fs.Flush() fs.Close() End Using End Sub End Using responseStream.Close() End Using response.Close() End Using End Sub -- View this message in context: http://www.nabble.com/Bug-In-Mono-FTP-System.Net.FtpWebRequest-tp19272346p19272346.html Sent from the Mono - Dev mailing list archive at Nabble.com. _______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list