I have trouble with uploading file to my ftp server in my Android device, in Editor it working perfect. Plz help me with it !!!
try
{
string filename = Path.GetFileName(/* local file path */);
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(/ link to file in my server */);
ftp.Credentials = new NetworkCredential(username_ftp, password_ftp);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(/* local file path */);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
}
catch (Exception ex)
{
throw ex;
}