www image not loading from folder in Build (works in editor) - Using windows

Hi

Spent the last few hours searching for an answer but nothing has worked so far.

Essentially I am loading all files (jpgs) from a folder as textures which are then converted to a sprites and stored in an array. Then I am loading each sprite into a gameobject.

This is working perfectly fine within the editor however when I build and run I get the following error.

You are trying to load data from a www
stream which had the following error
when downloading. Couldn’t open file
/test.jpg

This occurs for every image and nothing loads.

public class LoadImage : MonoBehaviour {

    //   public ArrayList imageBuffer = new ArrayList();
    public List<Texture2D> imageBuffer;
    public List<Sprite> loadedSprites;
    public GameObject textureTest;
    public GameObject testObject;
    string path = @"C:\Users\HWPC\Desktop\Test";

    void Start()
    {
        List<Sprite> everyone = new List<Sprite>();
        StartCoroutine("LoadImages");
    }

    IEnumerator LoadImages()
    {

        var info = new DirectoryInfo(path);
        var fileInfo = info.GetFiles();
        foreach (FileInfo file in fileInfo)
        {
            Debug.Log(file);

            string fullFilename = "file:///" + file.ToString();
            WWW www = new WWW(fullFilename);
           yield return www;

                Texture2D texTmp = new Texture2D(1024, 1024, TextureFormat.DXT1, false);
                try
                { www.LoadImageIntoTexture(texTmp); }
                catch { }
  

                imageBuffer.Add(texTmp);

                Sprite image = Sprite.Create(texTmp, new Rect(0, 0, texTmp.width, texTmp.height), new Vector2(0.5f, 0.5f), 100);
                loadedSprites.Add(image);
                testObject.GetComponent<Image>().sprite = image;
        }
    }
}

Advice on possible causes would be greatly appreciated !

Why use WWW when your loading them locally?

using System.IO;

public class LoadImage : MonoBehavior
{
    private Sprite LoadSpriteImage(string filepath)
    {
        if (File.Exists(filepath))
        {
            var photo = new Texture2D(4, 4);
            byte[] imageData = File.ReadAllBytes(filepath);
            photo.LoadImage(imageData);
            return Sprite.Create(photo, new Rect(0, 0, photo.width, photo.height), new Vector2(0.5f, 0.5f));
        }
        return null;
    }
}

Just add this method to your class and call on it inside your LoadImages method to get the sprites.