public void SendFile(string file_name) { EnsureMetadata(); var file_stream = new FileStream(file_name, FileMode.Open, FileAccess.Read); var write_file = new SendFileOperation(file_stream, null); length += file_stream.Length; if (chunk_encode) { SendChunk((int)file_stream.Length, false); } QueueWriteOperation(write_file); if (chunk_encode) { SendChunk(-1, false); } }
public void SendFile(string file_name) { EnsureMetadata(); var write_file = new SendFileOperation(file_name, null) { Chunked = chunk_encode, }; if (!chunk_encode) { pending_length_cbs++; FileSystem.GetFileLength(file_name, (l, e) => { if (l != -1) { write_file.SetLength(l); } LengthCallback(l, e); }); } else { write_file.Completed += delegate { length += write_file.Length; }; } // If chunk encoding is used the initial chunk will be written by the sendfile operation // because only it knows the length at the time. // QueueWriteOperation(write_file); if (chunk_encode) { SendChunk(-1, false); } }