From Xojo Documentation

Shared Method

WebFile.Open(file As FolderItem, [InMemory As Boolean = True]) As WebFile

New in 2010r4

Supported for all project types and targets.

Converts the passed FolderItem to a WebFile that can be downloaded. The entire file is loaded in memory when InMemory is True (the default). When InMemory is False, the file is referenced directly from the disk and data is accessed in 64K chunks.


Loading the entire file into memory means that the largest file that can be used is limited to the amount of free memory, up to a maximum of about 3GB or so.

When the inMemory parameter is False, the file is attempted to be loaded using 64K chunks. It is still possible, depending on the OS, for the entire file to be temporarily loaded into memory. This is not permanent as this memory will be released by the OS as part of its normal housecleaning.


If you want to download an existing file on the server, you need to create a WebFile that points to it and save the reference. The best way to do this is to use a property of the WebApplication class. In the App.Open event handler:

Var f As FolderItem = New FolderItem("MyFile.txt") // Get the file using a FolderItem
If f <> Nil And f.Exists Then
// Convert the FolderItem to a WebFile
App.MyFile = WebFile.Open(f) // MyFile is a property on the App object
App.MyFile.ForceDownload = True
End If

Now in a WebButton on a page, you can download this file like this:

If App.MyFile <> Nil Then
ShowURL(App.MyFile.URL) // Download the file
End If