I am downloading Image from a server and saving to a specific directory under. Assets/... . its working fine in editor but not working on android. I added storage read write permissions but still not working.
My code:
string remoteFile = "PROJECTS/ROBI/robidata01.txt";
string localFile = @"Assets/ROBI/DATA/robidata01.txt";
Download Function
public void DownloadTextFile(string remoteFile, string localFile)
{
try
{
ftpRequest = (FtpWebRequest)WebRequest.Create(host+""+remoteFile);
ftpRequest.Credentials = new NetworkCredential(user, pass);
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
ftpStream = ftpResponse.GetResponseStream();
/* Open a File Stream to Write the Downloaded File */
FileStream localFileStream = new FileStream(localFile, FileMode.Create);
/* Buffer for the Downloaded Data */
byte[] byteBuffer = new byte[bufferSize];
int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize);
/* Download the File by Writing the Buffered Data Until the Transfer is Complete */
try
{
while (bytesRead> 0)
{
localFileStream.Write(byteBuffer, 0, bytesRead);
bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize);
PlayerPrefs.SetInt("downloaded", 1);
FTP_Controller.instance.checkStatus();
FTP_Controller.isDownloaded = true;
}
}
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
/* Resource Cleanup */
localFileStream.Close();
ftpStream.Close();
ftpResponse.Close();
ftpRequest = null;
}
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
return;
}
manifest file:
\
↧