Not sure this helps or not.
I have images in this folder and I can use them for the site logo by
using /_layouts/images/xxx format by using the browser.
Is your code running a web context? ie, it is not a standalone
application, right? since _layouts is a virtual folder in IIS.