Loading a png from file without using Content pipeline. (solved)

I’m trying to load a png file that exists in my binary/executable directory, without using the Content pipeline.

using (var filestream = new FileStream("test.png", FileMode.Open)) { Texture2D myTexture = Texture2D.FromStream(GraphicsDevice, filestream); }

The file definitely exists but my program crashes when the texture2d line is executed. I’ve tried passing it the absolute path to the image, just the image filename etc, but it just won’t give.

I’m using the latest version of Monogame (from Nuget) using the .NET Core framework. Can someone please advise? My head is getting sore from bashing it on my keyboard.

Thank you

Edit: Ignore this, problem was totally unrelated and a dumb tired programmer error. Thanks

1 Like