Copy file from project resources

Hi,
Is it possible to copy a file which is embedded in project resources into desktop.

[code]Dim g As FolderItem
Dim h As FolderItem

g=GetFolderItem(document.docx)
h=SpecialFolder.Desktop

If Not h.Exists Then
g.CopyFileTo h
Else
MsgBox"file exists"
End If[/code]

even the same file is not exist on desktop, but still popping up the message that file exists.

thanks
regards,
arief

this isnt checking to see if the FILE exists but if the Desktop exists

you may want

Dim g As FolderItem
Dim h As FolderItem

g=GetFolderItem(document.docx)
h=SpecialFolder.Desktop

If h.Child(g.name).Exists Then
  g.CopyFileTo h.Child(g.name)
Else
  MsgBox"file exists"
End If

Thanks,

Now the message is gone. but still shows an error “NilObjectException”. it seems that the source embedded file does not exist.
What I did is, drag the file into xojo IDE project content and compile it. I did not put the file in the app. Folder, just tried to copy from resources. Is it possible to do in xojo ?

thanks
Regards,
Arief

If the file is in the App’s Resources folder you can use SpecialFolder.GetResource to get a FolderItem to it that you can then copy where you want.

https://documentation.xojo.com/api/deprecated/deprecated_class_members/specialfolder.getresource.html