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); }
public void SendFile(string file_name) { EnsureMetadata (); long length; using (var file_stream = new FileStream (file_name, FileMode.Open, FileAccess.Read)) length = file_stream.Length; var write_file = new SendFileOperation (file_name, length, null); length += length; if (chunk_encode) SendChunk ((int) length, false); QueueWriteOperation (write_file); if (chunk_encode) SendChunk (-1, false); }