//public TcpClient theSocket = null; public ServerControl(ServerForm serverForm) { // TODO: Complete member initialization this.serverForm = serverForm; this.CurrentDirectory = ""; this.RootDirectory = ""; ftpCommandHandler = new FTPCommandHandler(this); users = new Hashtable(); foreach (string userName in serverForm.listBoxUsers.Items) { users[userName.ToUpper()] = serverForm.textBoxPassword; } Thread litenerThread = new Thread(new ThreadStart(ListenerSession)); litenerThread.Start(); }
//This command comes immediately after the user command and completes the login and sets the access control privileges. public PasswordCommandHandler(FTPCommandHandler ftpCommandHandler) : base("PASS", ftpCommandHandler) { }
//Prints the name of the current working directory on return. public PwdCommandHandler(FTPCommandHandler ftpCommandHandler) : base("PWD", ftpCommandHandler) { }
//This command requests that the server transfers a copy of the file specified. //This transfer is to be done an the data port provided by the connection. //The status and contents of the file at the server remains unchanged. public RetrCommandHandler(FTPCommandHandler ftpCommandHandler) : base("RETR", ftpCommandHandler) { }
//Causes a list of files in the specified path to be transferred to the user. //If the pathname specified is a file then current information on that file will be sent. //If no path is specified the contents of the user's current working or default directory will be used. //This List is in a readable form and provides a list of files and their attributes. public ListCommandHandler(FTPCommandHandler ftpCommandHandler) : base("LIST", ftpCommandHandler) { }
public PasvCommandHandler(FTPCommandHandler ftpCommandHandler) : base("PASV", ftpCommandHandler) { }
//The USER command is required by the server for access to its file system. //This command will normally be the first command sent after the connection is made. //This has the effect of purging any user, password, and account information already //supplied at the beginning of the login sequence. public UserCommandHandler(FTPCommandHandler ftpCommandHandler) : base("USER", ftpCommandHandler) { }
//This command causes the server to accept data transferred via the data //connection and to store that data as a file at the server site. //If the file specified exists already on the server in the requested path, then the file shall be overwritten. //A new file is created on the server if the file specified does not already exist. public StoreCommandHandler(FTPCommandHandler ftpCommandHandler) : base("STOR", ftpCommandHandler) { }
public GetRootDirCommandHandler(FTPCommandHandler ftpCommandHandler) : base("GETROOTDIR", ftpCommandHandler) { }
//This command causes the file specified to be deleted on the server. //An extra level of protection (such as the query, "Do you really wish to delete?") //can be provided by many of the existing FTP clients. public DeleCommandHandler(FTPCommandHandler ftpCommandHandler) : base("DELE", ftpCommandHandler) { }
//This command causes the directory or subdirectory specified to be removed. //Typically only empty directories can be removed. //This command is usually preceded by a DELE (delete) command. public RemoveDirectoryCommandHandler(FTPCommandHandler ftpCommandHandler) : base("RMD", ftpCommandHandler) { }
public CwdCommandHandler(FTPCommandHandler ftpCommandHandler) : base("CWD", ftpCommandHandler) { }
//This command terminates the connection public QuitCommandHandler(FTPCommandHandler ftpCommandHandler) : base("QUIT", ftpCommandHandler) { }
protected FtpCommand(string sCommand, FTPCommandHandler ftpCommandHandler) { this.Command = sCommand; this.ftpCommandHandler = ftpCommandHandler; }