What am i doing wrong here? (file.exists)

Hi, im trying to tell if a file exists. I know the file is there, but it is just returing that its not. What have i done wrong? Here is the full code.

using UnityEngine;
using System.IO;

public class handleData : MonoBehaviour {

public static string datapath;
public static string correct;

void Start()
{
    datapath = Application.dataPath;
}

public static string HandleLogin(string username, string password)
{
    if (File.Exists(datapath + "/Resources/" + username + ".xml"))
    {
        correct = "ok";
    }
    else
    { 
        correct = "fail";
    }

        return correct;
}

}

I saw your file is under Resources, so why don’t you use Resource.Load for this check?

if ((Resources.Load("xmlfileName") as TextAsset) != null)
         correct = "ok";
    else
         correct = "fail";

And I think you should also check the username parameter. Hope this help.

Is there a reason why those properties have to be static?

Try to change datapath to handleData.datapath and correct to handleData.corrent

And also: Why waste space for storing a binary result (‘ok’ and ‘fail’) in a string instead of a boolean (true, false)?