I have been messing with the WWW class lately to download something from an ftp server I made with pagej.com. The error says “Transfer closed with X bytes remaining to read” and happens sometimes, about 50% of the times I try to download.
Here is a part of my code:
if(www.text != version && guiText.text == "Update!"){
guiText.text = "Downloading!";
www2 = new WWW (gameUrl);
www2downloading = true;
yield www2;
if (String.IsNullOrEmpty(www2.error)){
System.IO.Directory.CreateDirectory(Application.dataPath + "/Update");
System.IO.File.WriteAllBytes(Application.dataPath + "/Update" + "/Setup.exe", www2.bytes);
Application.OpenURL ((Application.dataPath) + "/Update" + "/Setup.exe");
Application.Quit();
guiText.text = "Play!";
}
else{
GameObject.Find("Progress").BroadcastMessage("Error", www2.error.ToString());
}
}
If I download it manually, its working just fine with no error. Is there a way I can fix it?