Set Desktop Picture to file in resource bundle

Hi there,

My program is supposed to download a picture and then make it the desktop background. I’m trying to use this:

set picfolder to (main bundle's resource path) as alias
		tell application "Finder" to set desktop picture to file "pic.png" of picfolder

But I get this error:

“File path to app’s resources folder, but not including pic.png was not found (-43”

Can anyone help me fix this? I’ve tried every way under the sun it seems and since none of the work I picked the shortest.

Hi,

try this


set thePic to (path to resource "pic.png")
tell application "Finder" to set desktop picture to thePic

That works good, thank you.

I don’t understand why my code didn’t work in the first place though.

resource path of main bundle returns a POSIX path, it cannot coerced to an alias directly