[mono-android] FTP Upload

Natanael sistemas at lorenzetti.com.br
Thu Feb 23 13:23:40 UTC 2012


I am with the following error in the command 

request.GetRequestStream Stream stream = () // ERROR: Not Connected


, the routine below, can someone help me.


Uri uri = new Uri(ftpHost + "/" + remoteFilePath);
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.CreateDefault( uri );                                              
request.KeepAlive = false;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UsePassive = false;
request.UseBinary = true;

Stream stream = request.GetRequestStream(); // ERROR: Not Connected

FileStream fileStream = File.OpenRead(localFilePath);
int Length = 2048; byte[] buffer = new byte[Length];                
int bytesToSend = fileStream.Read(buffer, 0, Length);                

    while (bytesToSend > 0)
    {        
        stream.Write(buffer, 0, bytesToSend);        
        bytesToSend = fileStream.Read(buffer, 0, Length);
    }

stream.Close();


--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/FTP-Upload-tp5507988p5507988.html
Sent from the Mono for Android mailing list archive at Nabble.com.


More information about the Monodroid mailing list