[Mono-bugs] [Bug 423194] New: Bug In Mono FTP System.Net.FtpWebRequest

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Sep 4 11:20:00 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=423194


           Summary: Bug In Mono FTP System.Net.FtpWebRequest
           Product: Mono: Class Libraries
           Version: 1.9
          Platform: i386
        OS/Version: SuSE Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ch.pourchier at sites.fr
         QAContact: mono-bugs at lists.ximian.com
          Found By: DeveloperNet


Description of Problem:
    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). 

    With my code I was able to download a file on the server
"ftp://ftp-developpez.com/konflor/Latex/formation/FormationLatex.pdf"
anonymously. But on my local server when I want to download a file with a
loggin and a password, my stream "ResponceStream" is empty and there is no
error. My code works on windows and ftp server! My FTP server is not under
windows!


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 



Steps to reproduce the problem:
1. 
2. 


Actual Results:
File with 0 bytes.

Expected Results:


How often does this happen? 
Always

Additional Information:
Solution that I have currently is through a socket with whom I send commands!


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list