internal protected virtual void InvokeOnDeleteDirectory(FtpFileEventArgs e) { if (this.OnDeleteDirectory != null) this.OnDeleteDirectory(this, e); }
public static void Cmd_MKD(Object sender, CommandEventArgs e) { FtpSession lSession = (FtpSession)e.Session; if (lSession.State == FtpState.LoggedIn) { if ((e.AllParameters.Length == 0) || (!ValidFilename(e.AllParameters))) { e.Connection.WriteLine("501 Syntax error in parameters or arguments."); return; } String lNewDir = e.AllParameters; if (lNewDir.StartsWith("/")) { lNewDir = ValidateDirectory(lNewDir); } else { String lTemp = lSession.Directory; if (!lTemp.EndsWith("/")) lTemp = lTemp + "/"; lNewDir = ValidateDirectory(lTemp + lNewDir); } FtpFileEventArgs lEventArgs = new FtpFileEventArgs(e.Session, e.Connection, e.Server); lEventArgs.FileName = lNewDir; try { ((FtpServer)e.Server).InvokeOnMakeDirectory(lEventArgs); } catch (FtpException ex) { e.Connection.WriteLine(ex.ToString()); return; } catch { e.Connection.WriteLine("500 Internal Error"); return; } if (lEventArgs.Ok) e.Connection.WriteLine(String.Format("257 \"{0}\" - Directory successfully created", lEventArgs.FileName)); else e.Connection.WriteLine("550 Permission Denied"); } else { e.Connection.WriteLine("503 Bad sequence of commands."); } }
protected override void InvokeOnDelete(FtpFileEventArgs ea) { VirtualFtpSession lSession = (VirtualFtpSession)ea.Session; IFtpFolder lFolder; string lFilename; lSession.CurrentFolder.FindBaseFolderForFilename(ea.FileName, out lFolder, out lFilename, lSession); lFolder.DeleteFile(lFilename, lSession); ea.Ok = true; }