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