GetFileAsArray Method
 On success, returns content of specified file 
  as byte array. On error, returns Empty.
  
  In ASP environment, this method is especially useful for downloading text or 
  binary files such as pictures, ZIP files, documents, etc. to client machines. 
  Common example of such files is message's attachments previously saved to disk. 
  To save attachments to disk, you can use SaveFile 
  method of Attachment object.
  
  Note: Message's attachments can be downloaded directly 
  from memory by using ContentAsArray 
  property of Attachment object. This is useful if you do not want to save 
  attachments to disk. 
| arrFile = ObjectName.GetFileAsArray([FilePath]) | ||
| Parameters: | ||
| FilePath As String | Path to the file, e.g. "C:\Data\picture01.gif" | |
| Return value As Variant | Byte array of the file's data. If an error occurs, return value is Empty | |
Usage example:
' This ASP-only sample downloads specified file to the client
Dim Msg, Arr
Set Msg = Server.CreateObject("MailBee.Message")
Arr = Msg.GetFileAsArray("D:\Docs\file.zip")
If Not IsEmpty(Arr) Then
  Response.BinaryWrite Arr
Else
  Response.Write "File not found"
End If
See Also:
 Attachment.SaveFile 
  Method
  Attachment.ContentAsArray Property 
Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.