.NET Event Extensions

A .NET Event Extension is a .NET assembly (usually a DLL) that contains a class that extends the class EnterpriseDT.Net.FtpServer.Trigger.Trigger. The assembly can be developed in C#, VB.NET or any other .NET language. If you don't already have Visual Studio then you can use one of Microsoft's free Visual Studio Express or Community products.

Creating a .NET Event Extension

General instructions on building CompleteFTP extensions may be found here.

.NET Event Extension classes must extend EnterpriseDT.Net.FtpServer.Trigger.Trigger and implement the OnTriggerEvent method. This method is called each time one of the following events occur: LogIn, LogOut, ChangeDirectory, UploadFile, DownloadFile, MoveFile, DeleteFile, CreateFolder, DeleteFolder and MoveFolder.

The OnTriggerEvent is passed a single argument of type TriggerEvent. This class contains various information about the event that occurred and the user-session in which it occurred.


The following example implements a minimal auditing .NET Event Extension, which simply logs all events to a CSV file in the user's temporary directory. This is based on the value of environment variables 'TEMP' of the system. The default path for this folder is C:\Users\{username}\AppData\Local\Temp or C:\Windows\Temp.

using System;
using System.IO;
using EnterpriseDT.Net.FtpServer.Trigger;

public class AuditingEventHandler : Trigger
	public override void OnTriggerEvent(TriggerEvent eventInfo)
		string auditFilePath = Path.Combine(Path.GetTempPath(), "audit.csv");
		using (StreamWriter auditFile = File.AppendText(auditFilePath))
			auditFile.WriteLine("{0:yyyy-MM-dd hh:mm:ss},{1},{2},{3},{4}", 
			DateTime.Now, eventInfo.EventType, eventInfo.Session.UserName, 
			eventInfo.Path, eventInfo.OldPath);

Adding AuditingEventHandler class into the CompleteFTP manager/Extension panels.

Login to your FTP client (FileZilla for example).

Then upload a file.

Check in C:\Users\{username}\AppData\Local\Temp or C:\Windows\Temp to see if the file audit.csv is there and that it has written the Login and Upload events.

Class Reference

Class: Trigger

All .NET Event Extensions must extend this class. Only the OnTriggerEvent method needs to be implemented. It is called every time an event occurs. If any initialization needs to be done then that may be placed in the Initialize method, and any required clean-up code may be placed in the Dispose method.

void OnTriggerEvent(TriggerEvent eventInfo)
Called every time an event occurs.
void Initialize(IPlugInInfo info)
Called when the Trigger is created. Perform any initialization tasks here. info.PlugInConfiguration contains the configuration entered by the user.
void Dispose()
Called when the Trigger is disposed of. Perform any clean-up tasks here

Class: TriggerEvent

Contains information describing a particular event

TriggerEventType EventType
Type of event. Possible values are LogIn, LogOut, ChangeDirectory, UploadFile, DownloadFile, MoveFile, DeleteFile, CreateFolder, DeleteFolder and MoveFolder.
ISession Session
Provides information about the current user-session, including the name of the user and the IP address of the client.
string Path
Path of file (if any)
string OldPath
Previous path of file (valid for MoveFile and MoveFolder events only).