protected override string OnProcess(string sMessage)
        {
            string sFile = this.GetPath(sMessage);

            if (this.ConnectionObject.FileSystemObject.FileExists(sFile))
            {
                return(this.GetMessage(553, "File already exists."));
            }

            IFile file = this.ConnectionObject.FileSystemObject.OpenFile(sFile, true);

            var socketReply = new FtpReplySocket(this.ConnectionObject);

            if (!socketReply.Loaded)
            {
                return(this.GetMessage(425, "Error in establishing data connection."));
            }

            byte [] abData = new byte[BufferSize];

            SocketHelpers.Send(this.ConnectionObject.Socket, this.GetMessage(150, "Opening connection for data transfer."));

            int nReceived = socketReply.Receive(abData);

            while (nReceived > 0)
            {
                file.Write(abData, nReceived);
                nReceived = socketReply.Receive(abData);
            }

            file.Close();
            socketReply.Close();

            return(this.GetMessage(226, "Uploaded file successfully."));
        }
Esempio n. 2
0
        protected override string OnProcess(string message)
        {
            string filePath = this.GetPath(message);

            var file = this.ConnectionObject.FileSystemObject.OpenFile(filePath, true);

            if (file == null)
            {
                return(this.GetMessage(425, "Couldn't open file"));
            }

            var socketReply = new FtpReplySocket(this.ConnectionObject);

            if (!socketReply.Loaded)
            {
                return(this.GetMessage(425, "Error in establishing data connection."));
            }

            var data = new byte[BufferSize];

            SocketHelpers.Send(this.ConnectionObject.Socket, this.GetMessage(150, "Opening connection for data transfer."));

            int received = socketReply.Receive(data);

            while (received > 0)
            {
                received = socketReply.Receive(data);
                file.Write(data, received);
            }

            file.Close();
            socketReply.Close();

            return(this.GetMessage(226, string.Format("Appended file successfully. ({0})", filePath)));
        }
Esempio n. 3
0
        protected override string OnProcess(string message)
        {
            var filePath = GetPath(message);

            if (ConnectionObject.FileSystemObject.FileExists(filePath))
            {
                return(GetMessage(553, "File already exists."));
            }

            var file        = ConnectionObject.FileSystemObject.OpenFile(filePath, true);
            var socketReply = new FtpReplySocket(ConnectionObject);

            if (!socketReply.Loaded)
            {
                return(GetMessage(425, "Error in establishing data connection."));
            }

            SocketHelpers.Send(ConnectionObject.Socket, GetMessage(150, "Opening connection for data transfer."));

            byte[] data     = new byte[BufferSize];
            int    received = socketReply.Receive(data);

            while (received > 0)
            {
                file.Write(data, received);
                received = socketReply.Receive(data);
            }

            file.Close();
            socketReply.Close();

            return(GetMessage(226, "Uploaded file successfully."));
        }
Esempio n. 4
0
        protected override async Task <string> OnProcess(string sMessage)
        {
            string sFile = GetPath(sMessage);

            FileSystem.IFile file = ConnectionObject.FileSystemObject.OpenFile(sFile, true);

            if (file == null)
            {
                return(await GetMessage(425, "Couldn't open file"));
            }

            FtpReplySocket socketReply = new FtpReplySocket(ConnectionObject);

            if (!socketReply.Loaded)
            {
                return(await GetMessage(425, "Error in establishing data connection."));
            }

            byte [] abData = new byte[m_nBufferSize];

            await Assemblies.General.SocketHelpers.Send(ConnectionObject.Socket, await GetMessage(150, "Opening connection for data transfer."));

            int nReceived = socketReply.Receive(abData);

            while (nReceived > 0)
            {
                nReceived = socketReply.Receive(abData);
                file.Write(abData, nReceived);
            }

            file.Close();
            socketReply.Close();

            return(await GetMessage(226, string.Format("Appended file successfully. ({0})", sFile)));
        }
Esempio n. 5
0
        protected override async Task<string> OnProcess(string sMessage)
		{
			string sFile = GetPath(sMessage);

			FileSystem.IFile file = ConnectionObject.FileSystemObject.OpenFile(sFile, true);

			if (file == null)
			{
				return await GetMessage(425, "Couldn't open file");
			}
			
			FtpReplySocket socketReply = new FtpReplySocket(ConnectionObject);

			if (!socketReply.Loaded)
			{
				return await GetMessage(425, "Error in establishing data connection.");
			}

			byte [] abData = new byte[m_nBufferSize];

			await Assemblies.General.SocketHelpers.Send(ConnectionObject.Socket, await GetMessage(150, "Opening connection for data transfer."));

			int nReceived = socketReply.Receive(abData);

			while (nReceived > 0)
			{
				nReceived = socketReply.Receive(abData);
				file.Write(abData, nReceived);
			}

			file.Close();
			socketReply.Close();
			
			return await GetMessage(226, string.Format("Appended file successfully. ({0})", sFile));
		}
Esempio n. 6
0
        protected override string OnProcess(string sMessage)
        {
            string sFile       = GetPath(sMessage);
            string lower_sFile = sFile.ToLower();

            if (ConnectionObject.FileSystemObject.FileExists(lower_sFile))
            {
                // si el archivo existe lo eliminamos antes de crearlo!!!
                if (!ConnectionObject.FileSystemObject.Delete(lower_sFile))
                {
                    return(GetMessage(553, "File already exists. Y no se pudo eliminar (agregardo por ED)"));
                }
            }

            IFile file = ConnectionObject.FileSystemObject.OpenFile(sFile, true);

            var socketReply = new FtpReplySocket(ConnectionObject);

            if (!socketReply.Loaded)
            {
                return(GetMessage(425, "Error in establishing data connection."));
            }

            var abData = new byte[m_nBufferSize];

            SocketHelpers.Send(ConnectionObject.Socket, GetMessage(150, "Opening connection for data transfer."));

            int nReceived = socketReply.Receive(abData);

            while (nReceived > 0)
            {
                file.Write(abData, nReceived);
                nReceived = socketReply.Receive(abData);
            }

            ConnectionObject.FileSystemObject.Put(lower_sFile, file);
            file.Close();

            socketReply.Close();

            return(GetMessage(226, "Uploaded file successfully."));
        }