Simple-FTP-Server - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Simple FTP Server
VB code
' Declare instance of wodFtpServer
Dim WithEvents FtpD As wodFTPDCom

Private Sub Command1_Click()
    FtpD.Port = 21 ' If not specified otherwise, wodFtpServer will listen on default protocol port (21 for FTP)
    
    ' Start listening for connections.
    FtpD.Start
End Sub

Private Sub Command2_Click()
    'Let's stop the server
    FtpD.Stop
End Sub

Private Sub Form_Load()
    'Initialize instance of wodFtpServer
    Set FtpD = New wodFTPDCom
End Sub

' Once LoginPassword event is triggered, we can choose to allow user to access server, or
' to deny him access to server. This is also a place to assign user his home directory
Private Sub FtpD_LoginPassword(ByVal User As wodFTPDComLib.IFtpUser, ByVal Login As String, ByVal Password As String, Action As wodFTPDComLib.FtpActions)
    Action = Allow
    User.HomeDir = "c:\"
End Sub
VB.Net code
Public WithEvents FtpD As wodFTPDComLib.wodFTPDCom
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Initialize instance of wodFtpServer
    FtpD = New wodFTPDComLib.wodFTPDCom
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    FtpD.Port = 21 ' If not specified otherwise, wodFtpServer will listen on default protocol port (21 for FTP)

    ' Start listening for connections.
    FtpD.Start()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    'Let's stop the server
    FtpD.Stop()
End Sub

' Once LoginPassword event is triggered, we can choose to allow user to access server, or
' to deny him access to server. This is also a place to assign user his home directory
Private Sub FtpD_LoginPassword(ByVal User As wodFTPDComLib.FtpUser, ByVal Login As String, ByVal Password As String, ByRef Action As wodFTPDComLib.FtpActions) Handles FtpD.LoginPassword
    Action = wodFTPDComLib.FtpActions.Allow
    User.HomeDir = "c:\"
End Sub
C# code
private wodFTPDComLib.wodFTPDCom FtpD;
private void Form1_Load(object sender, EventArgs e)
{
    //Initialize instance of wodFtpServer
    FtpD = new wodFTPDComLib.wodFTPDCom();

    FtpD.LoginPassword += new wodFTPDComLib._IwodFTPDComEvents_LoginPasswordEventHandler(FtpD_LoginPassword);
}

private void button1_Click(object sender, EventArgs e)
{
    FtpD.Port = 21; // If not specified otherwise, wodFtpServer will listen on default protocol port (21 for FTP)

    // Start listening for connections.
    FtpD.Start(FtpD.Port);
}

private void button2_Click(object sender, EventArgs e)
{
    //Let's stop the server
    FtpD.Stop();
}

// Once LoginPassword event is triggered, we can choose to allow user to access server, or
// to deny him access to server. This is also a place to assign user his home directory
void FtpD_LoginPassword(wodFTPDComLib.FtpUser User, string Login, string Password, ref wodFTPDComLib.FtpActions Action)
{
    Action = wodFTPDComLib.FtpActions.Allow;
    User.HomeDir = "c:\\";
}