protected override async Task<string> OnProcess(string sMessage) { string sFilePath = GetPath(sMessage); if (!ConnectionObject.FileSystemObject.FileExists(sFilePath)) { return await GetMessage(550, "File doesn't exist"); } FtpReplySocket replySocket = new FtpReplySocket(ConnectionObject); if (!replySocket.Loaded) { return await GetMessage(550, "Unable to establish data connection"); } await Assemblies.General.SocketHelpers.Send(ConnectionObject.Socket, "150 Starting data transfer, please wait...\r\n"); const int m_nBufferSize = 65536; FileSystem.IFile file = ConnectionObject.FileSystemObject.OpenFile(sFilePath, false); if (file == null) { return await GetMessage(550, "Couldn't open file"); } byte [] abBuffer = new byte[m_nBufferSize]; int nRead = file.Read(abBuffer, m_nBufferSize); while (nRead > 0 && await replySocket.Send(abBuffer, nRead)) { nRead = file.Read(abBuffer, m_nBufferSize); } file.Close(); replySocket.Close(); return await GetMessage(226, "File download succeeded."); }
protected override string OnProcess(string sMessage) { string sFilePath = GetPath(sMessage); if (!ConnectionObject.FileSystemObject.FileExists(sFilePath)) { return(GetMessage(550, "File doesn't exist")); } FtpReplySocket replySocket = new FtpReplySocket(ConnectionObject); if (!replySocket.Loaded) { return(GetMessage(550, "Unable to establish data connection")); } SocketHelpers.Send(ConnectionObject.Socket, "150 Starting data transfer, please wait...\r\n"); const int m_nBufferSize = 65536; IFile file = ConnectionObject.FileSystemObject.OpenFile(sFilePath, false); if (file == null) { return(GetMessage(550, "Couldn't open file")); } byte[] abBuffer = new byte[m_nBufferSize]; int nRead = file.Read(abBuffer, m_nBufferSize); while (nRead > 0 && replySocket.Send(abBuffer, nRead)) { nRead = file.Read(abBuffer, m_nBufferSize); } file.Close(); replySocket.Close(); return(GetMessage(226, "File download succeeded.")); }
protected override string OnProcess(string sMessage) { string sFilePath = this.GetPath(sMessage); if (!this.ConnectionObject.FileSystemObject.FileExists(sFilePath)) { return this.GetMessage(550, "File doesn't exist"); } var replySocket = new FtpReplySocket(this.ConnectionObject); if (!replySocket.Loaded) { return this.GetMessage(550, "Unable to establish data connection"); } SocketHelpers.Send(this.ConnectionObject.Socket, "150 Starting data transfer, please wait...\r\n"); const int bufferSize = 65536; IFile file = this.ConnectionObject.FileSystemObject.OpenFile(sFilePath, false); if (file == null) { return this.GetMessage(550, "Couldn't open file"); } var abBuffer = new byte[bufferSize]; int nRead = file.Read(abBuffer, bufferSize); while (nRead > 0 && replySocket.Send(abBuffer, nRead)) { nRead = file.Read(abBuffer, bufferSize); } file.Close(); replySocket.Close(); return this.GetMessage(226, "File download succeeded."); }
protected override string OnProcess(string message) { string filePath = this.GetPath(message); if (!this.ConnectionObject.FileSystemObject.FileExists(filePath)) { return(this.GetMessage(550, "File doesn't exist")); } var replySocket = new FtpReplySocket(this.ConnectionObject); if (!replySocket.Loaded) { return(this.GetMessage(550, "Unable to establish data connection")); } SocketHelpers.Send(this.ConnectionObject.Socket, "150 Starting data transfer, please wait...\r\n"); var file = this.ConnectionObject.FileSystemObject.OpenFile(filePath, false); if (file == null) { return(this.GetMessage(550, "Couldn't open file")); } const int BufferSize = 65536; var buffer = new byte[BufferSize]; int read = file.Read(buffer, BufferSize); while (read > 0 && replySocket.Send(buffer, read)) { read = file.Read(buffer, BufferSize); } file.Close(); replySocket.Close(); return(this.GetMessage(226, "File download succeeded.")); }
protected override async Task <string> OnProcess(string sMessage) { await Assemblies.General.SocketHelpers.Send(ConnectionObject.Socket, "150 Opening data connection for LIST\r\n"); string [] asFiles = null; string [] asDirectories = null; sMessage = sMessage.Trim(); string sPath = GetPath(""); if (sMessage.Length == 0 || sMessage[0] == '-') { asFiles = ConnectionObject.FileSystemObject.GetFiles(sPath); asDirectories = ConnectionObject.FileSystemObject.GetDirectories(sPath); } else { asFiles = ConnectionObject.FileSystemObject.GetFiles(sPath, sMessage); asDirectories = ConnectionObject.FileSystemObject.GetDirectories(sPath, sMessage); } string [] asAll = Assemblies.General.ArrayHelpers.Add(asDirectories, asFiles) as string[]; string sFileList = BuildReply(sMessage, asAll); FtpReplySocket socketReply = new FtpReplySocket(ConnectionObject); if (!socketReply.Loaded) { return(await GetMessage(550, "LIST unable to establish return connection.")); } await socketReply.Send(sFileList); socketReply.Close(); return(await GetMessage(226, "LIST successful.")); }
protected override string OnProcess(string message) { SocketHelpers.Send(ConnectionObject.Socket, "150 Opening data connection for LIST\r\n"); string[] asFiles = null; string[] asDirectories = null; message = message.Trim(); var path = GetPath(string.Empty); if (message.Length == 0 || message[0] == '-') { asFiles = ConnectionObject.FileSystemObject.GetFiles(path); asDirectories = ConnectionObject.FileSystemObject.GetDirectories(path); } else { asFiles = ConnectionObject.FileSystemObject.GetFiles(path, message); asDirectories = ConnectionObject.FileSystemObject.GetDirectories(path, message); } var asAll = ArrayHelpers.Add(asDirectories, asFiles) as string[]; var fileList = BuildReply(message, asAll); var socketReply = new FtpReplySocket(ConnectionObject); if (!socketReply.Loaded) { return(GetMessage(550, "LIST unable to establish return connection.")); } socketReply.Send(fileList); socketReply.Close(); return(GetMessage(226, "LIST successful.")); }
protected override async Task<string> OnProcess(string sMessage) { await Assemblies.General.SocketHelpers.Send(ConnectionObject.Socket, "150 Opening data connection for LIST\r\n"); string [] asFiles = null; string [] asDirectories = null; sMessage = sMessage.Trim(); string sPath = GetPath(""); if (sMessage.Length == 0 || sMessage[0] == '-') { asFiles = ConnectionObject.FileSystemObject.GetFiles(sPath); asDirectories = ConnectionObject.FileSystemObject.GetDirectories(sPath); } else { asFiles = ConnectionObject.FileSystemObject.GetFiles(sPath, sMessage); asDirectories = ConnectionObject.FileSystemObject.GetDirectories(sPath, sMessage); } string [] asAll = Assemblies.General.ArrayHelpers.Add(asDirectories, asFiles) as string[]; string sFileList = BuildReply(sMessage, asAll); FtpReplySocket socketReply = new FtpReplySocket(ConnectionObject); if (!socketReply.Loaded) { return await GetMessage(550, "LIST unable to establish return connection."); } await socketReply.Send(sFileList); socketReply.Close(); return await GetMessage(226, "LIST successful."); }
protected override string OnProcess(string message) { SocketHelpers.Send(this.ConnectionObject.Socket, "150 Opening data connection for LIST\r\n"); string [] asFiles = null; string [] asDirectories = null; message = message.Trim(); string path = this.GetPath(""); if (message.Length == 0 || message[0] == '-') { asFiles = this.ConnectionObject.FileSystemObject.GetFiles(path); asDirectories = this.ConnectionObject.FileSystemObject.GetDirectories(path); } else { asFiles = this.ConnectionObject.FileSystemObject.GetFiles(path, message); asDirectories = this.ConnectionObject.FileSystemObject.GetDirectories(path, message); } var asAll = ArrayHelpers.Add(asDirectories, asFiles) as string[]; string sFileList = this.BuildReply(message, asAll); var socketReply = new FtpReplySocket(this.ConnectionObject); if (!socketReply.Loaded) { return this.GetMessage(550, "LIST unable to establish return connection."); } socketReply.Send(sFileList); socketReply.Close(); return this.GetMessage(226, "LIST successful."); }