# How can I read a value from a file accessed via the Internet?

I have made text file and I put it on Dropbox, I have in this text file a value. From my code, I want to check if this value is 1.

I have tried this code, inspired by the Unity example, but it looks like I'm not able to reach the file.

void Start()
{
StartCoroutine(GetText());
}

IEnumerator GetText()
{

UnityWebRequest www = UnityWebRequest.Get("https://www.dropbox.com/s/6jkhtnpskzsi5pj/TestTXT.txt?dl=0");
yield return www.SendWebRequest();

if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
// Show results as text
// Or retrieve results as binary data
}
}


It looks like Unity was not able to download the file. To fix this, I set the dl=1 in the Dropbox URL, instead of dl=0.

Here is the code that made it work for me:

public class DMROnline : MonoBehaviour
{
public string Active;
public string Disable;

public TextAsset textFile;
void Start()
{
StartCoroutine(GetText());
}

IEnumerator GetText()
{
yield return www.SendWebRequest();

if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
// Show results as text
// Or retrieve results as binary data

Console.WriteLine(pathTxt);
Debug.Log(pathTxt);
}
}
}


I also had to make sure that the folder holding the file is public, not private.

• UnityWebRequest.Get(url) is the thing which solved it for me instead of using new UnityWebRequest(url) Jun 17 at 23:20