SaveBinaryAs Method

Object: SoftArtisans.FileUp
Syntax: SaveBinaryAs([in] Filename As String)
Description:

This method saves the raw HTTP Post stream to the web server's hard disk without any interpretation.

If no path is specified (for example, fileUpload.SaveBinaryAs "FileX.ext"), the value of the Path property is used. For more efficient processing, it is recommended that you always use set the Path property before saving any files.

If the Filename parameter includes a file path, it must specify an absolute path (for example, "C:\UploadDir\FileX.ext"). You cannot pass a relative path to the SaveBinaryAs method.

The SaveBinaryAs method cannot be used in conjunction with other methods that interpret the HTTP Post stream (for example, methods that get form values or save a decoded upload to disk).

In ASP.NET, this method can be useful in determining in the HttpModule is configured correctly and properly stripping the uploaded file's binary out of the Request and replacing it with a pointer to the cached file.

Examples:

The following sets the Path property to C:\Temp and saves the raw HTTP Post stream on the Web server at C:\Uploads:

ASP <%
'--- Instantiate FileUp
Set fileUpload = Server.CreateObject("SoftArtisans.FileUp")

'--- Cache upload to C:\Temp
fileUpload.Path = "C:\Temp"

'--- Save raw stream to C:\Uploads\file.txt
fileUpload.SaveBinaryAs "C:\Uploads\file.txt"
%>
C# //--- Instantiate FileUp
FileUp fileUpload = new FileUp(Context);

//--- Set default save location to C:\Temp
//--- (Cache location is set in registry since HttpModule is used
//--- with .NET)
fileUpload.Path = "C:\\Temp";

//--- Save raw stream to C:\Uploads\file.txt
fileUpload.SaveBinaryAs("C:\\Uploads\\file.txt");
VB.NET '--- Instantiate FileUp
FileUp fileUpload = new FileUp(Context);

'--- Set default save location to C:\Temp
'--- (Cache location is set in registry since HttpModule is used
'--- with .NET)
fileUpload.Path = "C:\Temp"

'--- Save raw stream to C:\Uploads\file.txt
fileUpload.SaveBinaryAs("C:\Uploads\file.txt")

Copyright © 2010 SoftArtisans, Inc. All rights reserved.