WebFile downloading

I have, basically, copied the example for how to create and download a text file created by my web app, however, I keep getting an error on the last line that is supposed to download the file… that is:

“You must use the value returned by this function”

What am I missing here?

'code below

TextFile = New WebFile // TextFile is a property of the web page
TextFile.MimeType = “text/plain”
TextFile.ForceDownload = True // If False, the browser may try to display the file instead of download it
TextFile.FileName = “client_email.csv”
var emails as RecordSet = session.data.SqlSelect(“Select FIRST_NAME, LAST_NAME, EMAIL FROM CLIENTS where ACTIVE = ‘True’”)
var nline as string=""

while not emails.eof
nline=emails.Field(“FIRST_NAME”).StringValue + “,” + emails.Field(“LAST_NAME”).StringValue + “,” + emails.Field(“EMAIL”).StringValue
txtFiles.Text=txtFiles.text + nline
emails.MoveNext
Wend

TextFile.Data = txtFiles.Text

TextFile.Download

The documentation has this code:

If TextFile.Download Then // This causes the file to be downloaded
  // Download requested
End If

also shows:

System.GotoURL(TextFile.URL) // This causes the file to be downloaded

If the above doesn’t work then the documentation need updates.

1 Like

Thank you Alberto, just adding the line :slight_smile:

If TextFile.Download Then // This causes the file to be downloaded
// Download requested
End If

made it work!