I would like offer download from a standalone xojo app (Microsoft). but I don’t know how to do this. The following source code I programmed, but it doesn’t work:
dim wf as new WebFile
dim s as string
s = "AIT_ATTACHMENTS/TEXTFILE.PDF"
dim fd as FolderItem = GetFolderItem(s)
if fd <> nil and fd.Exists then
wf = WebFile.Open(fd)
wf.ForceDownload = true
if wf <> nil then
msgbox " not found " + s + " --- " + app.ExecutableFile.Parent.URLPath
The folder “AIT_ATTACHMENTS” is in the same folder as the standalone execution file.
Are there any more explanations or examples available for handling files?
I don’t know how to specify a path and filenames. I don’t know, what kind of tags I have to use. For example: “C:/AITTACHEMENT…”.
Can anybody give me a tip? Thank’s in advance?
Edit (Paul): Added Code tag.
I offer downloads to my customers with a program I started with an example that comes with Xojo :
Xojo 2014 Release 1/Example Projects/Web/Downloading/Downloading.xojo_binary_project
If the OS is Windows then your folder delimiter is backwards. Windows uses \ not /. To make this xplat you should do
s = "AIT_ATTACHMENTS"
dim fd as FolderItem = GetFolderItem(s).child("TEXTFILE.PDF")
Thank you both. Now it works. That is the running source code:
dim s as string
Dim f As Folderitem = App.ExecutableFile.Parent.Child(s)
s = "AIT_ATTACHMENTS\\TEXTFILE.PDF"
If f <> Nil And f.Exists Then
Session.DownloadFile = WebFile.Open(f)
Session.DownloadFile.ForceDownload = False
If Session.DownloadFile <> Nil Then
MsgBox("The selected file is not available.")
I used a webfile property of the session (property name = DownloadFile) instead of a declared variable, how ever.
Because of the behaviour in Internet Explorer I didn’t used “ShowURL”, because the user have to use the “Back”-button. In that case the user have to login again. It’s not a good behaviour.