Delete Method

Object: SoftArtisans.SAFile
Syntax: Delete([in,optional] Filename As String)
Description:

This method deletes a file from the web server's hard disk.

If you specify a filename, it must contain the entire valid path.

If you do not specify a filename, the current uploaded file is deleted. This effectively allows you to cancel an upload.

See also the Delete method for the SAFileUp object.

Examples:

Delete an uploaded file that was saved to disk:

ASP <%
fileUpload.Path = "C:\MySaveLocation"
Set file = fileUpload.Form("MyFile1")

'--- Save the file to C:\MySaveLocation
file.Save

'--- Delete the file that you just saved.
file.Delete
%>
C# fileUpload.Path = @"C:\MySaveLocation";
SaFile file = (SaFile)fileUpload.Form["MyFile1"];

//--- Save the file to C:\MySaveLocation
file.Save();

//--- Delete the file that you just saved
file.Delete();
VB.NET fileUpload.Path = "C:\MySaveLocation"
Dim file As SaFile = CType(fileUpload.Form("MyFile1"), SaFile)

'--- Save the file to C:\MySaveLocation
file.Save()

'--- Delete the file that you just saved
file.Delete()

Delete uploads that are not gifs or jpegs:

ASP <%
Set file = fileUpload.Form("myFile");

strContentType = fileUpload.ContentType

If (strContentType = "image/gif") Then

file.Save

ElseIf (strContentType = "image/pjpeg") Then

file.Save

Else

file.Delete

End If
C# SaFile file = (SaFile)fileUpload.Form["myFile"];

String strContentType;
strContentType = fileUpload.ContentType;

switch(strContentType)
{
case "image/gif":
file.Save();
break;
case "image/pjpeg":
file.Save();
break;
default:
file.Delete();
break;
}
VB.NET Dim file As SaFile
file = CType(fileUpload.Form("myFile"), SaFile)

Dim strContentType as String
strContentType = file.ContentType

Select Case strContentType
Case "image/gif"
file.Save
Case "image/pjpeg"
file.Save
Case Else
file.Delete
End Select

Copyright © 2010 SoftArtisans, Inc. All rights reserved.