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; }
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; }
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); }