﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using FuzzyCore.Server;

namespace FuzzyCore.Commands
{
    public class GetFile
    {
        ConsoleMessage Message = new ConsoleMessage();
        public void GetFileBytes(Data.JsonCommand Command)
        {
            try
            {
                byte[] file = File.ReadAllBytes(Command.FilePath + "\\" + Command.Text);
                if (file.Length > 0)
                {
                    SendDataArray(file, Command.Client_Socket);
                    Message.Write(Command.CommandType,ConsoleMessage.MessageType.SUCCESS);
                }
            }
            catch (Exception ex)
            {
                Message.Write(ex.Message, ConsoleMessage.MessageType.ERROR);
            }
        }
        public void SendDataArray(byte[] Data, Socket Client)
        {
            try
            {
                Thread.Sleep(100);
                Client.Send(Data);
            }
            catch (Exception ex)
            {
                Message.Write(ex.Message, ConsoleMessage.MessageType.ERROR);
            }
        }
    }
}

﻿using FuzzyCore.Data;
using FuzzyCore.Server;
using System;
using System.IO;

namespace FuzzyCore.Commands
{
    public class GetFile
    {
        ConsoleMessage Message = new ConsoleMessage();
        private String FilePath;
        private String FileName;
        private JsonCommand mCommand;
        public GetFile(Data.JsonCommand Command)
        {
            FilePath = Command.FilePath;
            FileName = Command.Text;
            this.mCommand = Command;
        }
        bool FileControl()
        {
            FileInfo mfileInfo = new FileInfo(FilePath);
            return mfileInfo.Exists;
        }
        public byte[] GetFileBytes()
        {
            if (FileControl())
            {
                byte[] file = File.ReadAllBytes(FilePath + "/" + FileName);
                return file;
            }
            return new byte[0];
        }
        public string GetFileText()
        {
            if (FileControl())
            {
                return File.ReadAllText(FilePath + "/" + FileName);
            }
            return "";
        }
    }
}

Delete sender and edit constructor functions
Delete sender and edit constructor functions
