FileUp Object

The FileUp object is the principal object used for all of FileUp's functions including file upload, file download, and database manipulation.

To use any upload or download function in SoftArtisans FileUp, you must create an instance of the FileUp object.

To do this in ASP, use the built-in Server.CreateObject function.

<% Set fileUpload = Server.CreateObject("SoftArtisans.FileUp") %>

After that, all methods and properties are available to you.

In ASP.NET, you should include the SoftArtisans.Net namespace. It is also recommended that you declare an object for FileUp prior to a try...catch...finallycode block, and then, instatiate FileUp within the try section of the block. When FileUp is instantiated, pass it the context of the Request.

When you are finished using the FileUp object, you must remember to call Dispose() on the FileUp object in the finally section.

For more information on the technical reasons that this structure is advised, please see Properly Disposing of Resources in .NET

C# using SoftArtisans.Net;


...(namespace, class, and other declaration code, )....

private void ProcessUpload()
{
//--- Declare the FileUp object
FileUp fileUpload = null;

try
{
fileUpload = new FileUp (Context);

...(upload processing code)

     }
catch (Exception ex)
{

...(error handling code here)

     }
finally
{
//--- Always call Dispose
//--- in the finally block
if (fileUpload != null)
fileUpload.Dispose();
fileUpload = null;
}
}
VB.NET Imports SoftArtisans.Net

...(namespace, class, and other declaration code, )....

Private Sub ProcessUpload()
'--- Declare the FileUp object
Dim fileUpload As FileUp
Try
fileUpload = New FileUp (Context)

...(upload processing code)

     Catch ex As System.Exception

...(error handling code here)

     Finally
'--- Always call FileUp.Dispose
'--- in the finally block
If Not (fileUpload Is Nothing) Then
fileUpload.Dispose()
End If
fileUpload = Nothing
End Try
End Sub

(...)

Copyright © 2010 SoftArtisans, Inc. All rights reserved.