Hi, I check for a file in a path.If the file is not present I wanto download from the server.The code I tried is given below .Even though the file is present in the path it again downloads it?What is the problem?
IEnumerator DownloadWorldmap()
{
//string datapath1 = "data.txt";
//string datapath2 = "world.txt";
//StartCoroutine(CheckTextFile(datapath1));
//StartCoroutine(CheckTextFile(datapath2));
for (int i = 0; i < Allfilenames.Count;i++)
{
Debug.Log("File name === "+Allfilenames[i]);
WWW localFile = new WWW(Application.persistentDataPath+"/"+Allfilenames[i]);
yield return localFile;
if (localFile.error == null)
{
Debug.Log("File Already There");
}
else
{
var uwr = new UnityWebRequest("https://test.com/casino/hariupload/uploads/" + Allfilenames[i], UnityWebRequest.kHttpVerbGET);
string path = Path.Combine(Application.persistentDataPath, Allfilenames[i]);
uwr.downloadHandler = new DownloadHandlerFile(path);
yield return uwr.SendWebRequest();
if (uwr.isNetworkError || uwr.isHttpError)
Debug.LogError(uwr.error);
else
Debug.Log("File successfully downloaded and saved to " + path);
}
}
}
I am getting this message in the Log “File successfully downloaded and…” 4 times as there are 4 files present in the server.