ftp without usb cable does not work

Asked

Viewed 28 times

1

I’ve had a problem for days and I can’t fix it. I set up a FTP routine on Xamarin and it works perfectly as long as the USB cable (used for debugging) is connected (note and smart) or if I open Xamarin and run in debug mode the routine works perfectly. If I take the cable and run the application on mobile, routine records a piece of the image but it does not return. I generated a release and it also records part of the image and the routine does not return.

Would anyone know what’s going on?

below the code for ftp

public void sendAPicture(byte[] picture, int _cdn_stb, string _imb_prt_mnu)
{
    string _cds_stb = _cdn_stb.ToString("0000");        
    string ftpUser = "sasasas";
    string ftpPassword = "sasasas";
    string ftpfullpath = "ftp://www.meusite.com.br/wordpress/imagens/" + _cds_stb + "/" + _imb_prt_mnu; ;

    FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpfullpath));

    //userid and password for the ftp server  
    ftp.Credentials = new NetworkCredential(ftpUser, ftpPassword);

    ftp.KeepAlive = true;
    ftp.UseBinary = true;
    ftp.UsePassive = true;
    ftp.Method = WebRequestMethods.Ftp.UploadFile;
    ftp.ContentLength = picture.Length;

    Stream ftpstream = ftp.GetRequestStream();

    var grava = new Task(() =>
    {
        ftpstream.Write(picture, 0, picture.Length);
    });
    grava.Start();
    grava.Wait(TimeSpan.FromSeconds(10));

    ftpstream.Close();
}
  • I don’t know how much this can influence , but you’re not doing the dispose stream. Ever tried to encapsulate its use within a block using? The result is the same?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.