Example #1
0
        public FileStreamReceiver(NetClient client, string filePath, FileTransferMessageType fileType, OnFinished onFinished)
        {
            this.client = client;

            this.downloadFolder = filePath;
            this.fileType       = fileType;

            this.onFinished = onFinished;

            Status = FileTransferStatus.NotStarted;
        }
Example #2
0
        private FileStreamSender(NetConnection conn, string filePath, FileTransferMessageType fileType)
        {
            connection  = conn;
            inputStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
            chunkLen    = connection.Peer.Configuration.MaximumTransmissionUnit - 100;
            tempBuffer  = new byte[chunkLen];
            sentOffset  = 0;

            FilePath = filePath;
            FileName = Path.GetFileName(filePath);

            this.fileType = fileType;

            Status = FileTransferStatus.NotStarted;

            startingTime = DateTime.Now;
        }
Example #3
0
        public static FileStreamSender Create(NetConnection conn, string filePath, FileTransferMessageType fileType)
        {
            if (!File.Exists(filePath))
            {
                DebugConsole.ThrowError("Sending a file failed. File ''" + filePath + "'' not found.");
                return(null);
            }

            FileStreamSender sender = null;

            try
            {
                sender = new FileStreamSender(conn, filePath, fileType);
            }

            catch (Exception e)
            {
                DebugConsole.ThrowError("Couldn't open file ''" + filePath + "''", e);
            }

            return(sender);
        }