Mar 2, 2014 06:14 PM
(This post was last modified: Apr 10, 2014 01:57 PM by PathogenDubz.)
zFTP
Custom Made Dynamic FTP Library
Features- Almost all Standard FTP Commands are Implemented
- Ability To Add Custom Commands
- Fast, Reliable, & Stable
- Easy To Use Event Driven Framework
- Simple Client Wrapper Included
Example Code Snippets
Create a zFTP Server
Code Public WithEvents FtpServer As New FTPServer(21, True)
Add the Messagebox.Show Function to your Server
Code FtpServer.CustomCommands.Add("MSG", New Action(Of String)(AddressOf MessageBox.Show))
Disable A Command
Code Private Sub FtpServer_PreCommandExecute(sender As FTPClient, e As FTPClient.PreCommandExecuteEventArgs) Handles FtpServer.PreCommandExecute
If e.Command = FtpCommand.RemoveDirectory Then
e.Cancel = True
ElseIf e.Command = "MSG" Then
e.Cancel = True
End If
End Sub
Add Accounts to your Server ( Hard Coded )
Code Private Sub FtpServer_OnUserAuthenticationRequired(ByRef User As FTPUser) Handles FTPServer.OnUserAuthenticationRequired
If User.Username = Username And User.Password = Password Then
User.isAuthenticated = True
User.StartDirectory = "C:\Users\Administrator\Desktop"
End If
End Sub
Add Accounts to your Server ( Dynamically Coded - CAN be used with SQL Servers )
Code Private AccountDatabase As New Dictionary(Of String, String) From {{"MyUsername", "MyPassword"}, _
{"Account1", "Account1Password"}, _
{"Account2", "Account2Password"}, _
{"Account3", "Account3Password"}, _
{"Account4", "Account4Password"}, _
{"Account5", "Account5Password"}}
Private Sub FtpServer_OnUserAuthenticationRequired(ByRef User As FTPUser) Handles FtpServer.OnUserAuthenticationRequired
'Check if the given username is in the database
If AccountDatabase.ContainsKey(User.Username) Then
'Check if the given password matches the database password
If AccountDatabase(Username) = User.Password Then
'Authenticate the User & set their start directory
User.isAuthenticated = True
User.CanExecuteCustomCommands = True
User.StartDirectory = "C:\FtpUsers\" & Username
End If
End If
End Sub
Override existing Commands
Code Public WithEvents FtpServer As New FTPServer(21, True, GetType(CustomFtpClient))
Public Class CustomFtpClient
Inherits zFTP.FTPClient
Public Overrides Sub STOR(CmdArguments As String)
' If Hosting files on a web server
Dim Types As String() = {"php", "asax", "ascx", "ashx", "asmx", "aspx", "axd", "cs", "csproj", "licx", "rem", "resources", "resx", "soap", "vb", "vbproj", "vsdisco", "webinfo"}
If Types.Contains(IO.Path.GetExtension(CmdArguments).Remove(0, 1).ToLower) Then
Reply("426 Access Denied.")
Return
End If
'Store the file on the server
MyBase.STOR(CmdArguments)
'Create a custom STOR action
MsgBox("Stored File '" & CmdArguments & "'")
End Sub
End Class
Ftp Client Wrapper & Server Test Code
Code Private Sub UploadFile()
Dim FtpClient As New zFTP.Client.FtpClientWrapper("ftp://127.0.0.1", "Username", "Password") With {.Port = 21}
Dim OpenFileDialog As New Forms.OpenFileDialog
OpenFileDialog.ShowDialog()
If OpenFileDialog.FileName <> Nothing Then
FtpClient.UploadFile(OpenFileDialog.FileName)
End If
End Sub
DOWNLOAD zFTP ( Includes Sample Project )
7 years experience with the .NET Framework. Have a question? Inbox me.
Interesting project.
You've made everything from scratch?
If so, great work =)
(Mar 2, 2014 06:21 PM)ovac Wrote: Interesting project.
You've made everything from scratch?
If so, great work =)
I have to admit a lot of it was me googling everything, but yeah everything but the datasocket & listener classes themselves.
Thanks man
7 years experience with the .NET Framework. Have a question? Inbox me.
Screenshots would be nice, looks like a really good project though!
(Mar 2, 2014 06:42 PM)Hexology Wrote: Screenshots would be nice, looks like a really good project though!
Why would I screenshot a class library? :P
7 years experience with the .NET Framework. Have a question? Inbox me.
can u post the link as text have problem to download tnx
This looks amazing mate, nice job on this library. Keep it up!
Mar 3, 2014 11:30 AM
(This post was last modified: Mar 3, 2014 12:17 PM by PathogenDubz.)
(Mar 3, 2014 01:37 AM)Only3 Wrote: can u post the link as text have problem to download tnx
Sorry about that! I keep forgetting to have the SQL database automatically update the encryption key.
It should be fixed now. :)
(Mar 3, 2014 06:40 AM)Weakky. Wrote: This looks amazing mate, nice job on this library. Keep it up!
Thanks man, I really appreciate it! :)
7 years experience with the .NET Framework. Have a question? Inbox me.
what the AlexPilotti.FTPS.Client for do use it with ur lib
Mar 3, 2014 12:46 PM
(This post was last modified: Mar 3, 2014 12:56 PM by PathogenDubz.)
(Mar 3, 2014 12:42 PM)Only3 Wrote: what the AlexPilotti.FTPS.Client for do use it with ur lib
It's for the sample project that i put together. No other FTP client allows the use of custom commands.
Edit: To be clear, the FtpServer does not require this library.
7 years experience with the .NET Framework. Have a question? Inbox me.
(Mar 2, 2014 06:44 PM)PathogenDubz Wrote: Why would I screenshot a class library? :P
Oh my bad, thought you'd have an example project haha, well either way looks interesting.
Mar 3, 2014 05:59 PM
(This post was last modified: Mar 3, 2014 06:55 PM by PathogenDubz.)
(Mar 3, 2014 03:25 PM)Hexology Wrote: Oh my bad, thought you'd have an example project haha, well either way looks interesting.
No worries man
I did include a test project but it's 99% about the code and not so much about the UI hahah
(see below)
[img]http://zscrn.us/GIe5Pnemgl.png[/img]
[img]http://zscrn.us/yHR7Q6bSy0.png[/img]
Edit: Updated the source & Library. More features added and cleaned up a few things.
7 years experience with the .NET Framework. Have a question? Inbox me.
u should add online option to control it (ftp site)
(Mar 4, 2014 12:51 AM)Only3 Wrote: u should add online option to control it (ftp site)
I think you're misunderstanding what this project is exactly.
Basically, if you've ever heard of FileZilla you know they have a FTP server software that allows you to make a quick FTP server without the hassle of using IIS. This is exactly that except for .NET! It's fully managed and features events to make it really simple. The FTPClient class is also fully customizable so you can use your SQL servers to interface with how the users are authenticated.
If you would like to see a live version of a website + zFTP then check out http://zscrn.us/
7 years experience with the .NET Framework. Have a question? Inbox me.
|