# < Summary

Information

Class: | Renci.SshNet.Sftp.Requests.SftpWriteRequest
Assembly: | Renci.SshNet
File(s): | \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpWriteRequest.cs

Line coverage
78%

Covered lines: | 29
Uncovered lines: | 8
Coverable lines: | 37
Total lines: | 101
Line coverage: | 78.3%

Branch coverage
N/A

Covered branches: | 0
Total branches: | 0
Branch coverage: | N/A

Method coverage

Feature is only available for sponsors

Upgrade to PRO version

# Metrics

Method | Branch coverage | Cyclomatic complexity | Line coverage
--- | --- | --- | ---
get_SftpMessageType() | 100% | 1 | 100%
get_Handle() | 100% | 1 | 100%
get_ServerFileOffset() | 100% | 1 | 100%
get_Data() | 100% | 1 | 100%
get_Offset() | 100% | 1 | 100%
get_Length() | 100% | 1 | 100%
get_BufferCapacity() | 100% | 1 | 100%
.ctor(...) | 100% | 1 | 100%
LoadData() | 100% | 1 | 0%
SaveData() | 100% | 1 | 100%

# File(s)

## \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpWriteRequest.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using Renci.SshNet.Sftp.Responses;`
|  | `3` |  | ``
|  | `4` |  | `namespace Renci.SshNet.Sftp.Requests`
|  | `5` |  | `{`
|  | `6` |  | `internal sealed class SftpWriteRequest : SftpRequest`
|  | `7` |  | `{`
|  | `8` |  | `public override SftpMessageTypes SftpMessageType`
|  | `9` |  | `{`
| 11808 | `10` |  | `get { return SftpMessageTypes.Write; }`
|  | `11` |  | `}`
|  | `12` |  | ``
| 11808 | `13` |  | `public byte[] Handle { get; private set; }`
|  | `14` |  | ``
|  | `15` |  | `/// <summary>`
|  | `16` |  | `/// Gets the zero-based offset (in bytes) relative to the beginning of the file that the write`
|  | `17` |  | `/// must start at.`
|  | `18` |  | `/// </summary>`
|  | `19` |  | `/// <value>`
|  | `20` |  | `/// The zero-based offset (in bytes) relative to the beginning of the file that the write must`
|  | `21` |  | `/// start at.`
|  | `22` |  | `/// </value>`
| 7875 | `23` |  | `public ulong ServerFileOffset { get; private set; }`
|  | `24` |  | ``
|  | `25` |  | `/// <summary>`
|  | `26` |  | `/// Gets the buffer holding the data to write.`
|  | `27` |  | `/// </summary>`
|  | `28` |  | `/// <value>`
|  | `29` |  | `/// The buffer holding the data to write.`
|  | `30` |  | `/// </value>`
| 7875 | `31` |  | `public byte[] Data { get; private set; }`
|  | `32` |  | ``
|  | `33` |  | `/// <summary>`
|  | `34` |  | `/// Gets the zero-based offset in <see cref="Data" /> at which to begin taking bytes to`
|  | `35` |  | `/// write.`
|  | `36` |  | `/// </summary>`
|  | `37` |  | `/// <value>`
|  | `38` |  | `/// The zero-based offset in <see cref="Data" /> at which to begin taking bytes to write.`
|  | `39` |  | `/// </value>`
| 7875 | `40` |  | `public int Offset { get; private set; }`
|  | `41` |  | ``
|  | `42` |  | `/// <summary>`
|  | `43` |  | `/// Gets the length (in bytes) of the data to write.`
|  | `44` |  | `/// </summary>`
|  | `45` |  | `/// <value>`
|  | `46` |  | `/// The length (in bytes) of the data to write.`
|  | `47` |  | `/// </value>`
| 11808 | `48` |  | `public int Length { get; private set; }`
|  | `49` |  | ``
|  | `50` |  | `protected override int BufferCapacity`
|  | `51` |  | `{`
|  | `52` |  | `get`
| 3933 | `53` |  | `{`
| 3933 | `54` |  | `var capacity = base.BufferCapacity;`
| 3933 | `55` |  | `capacity += 4; // Handle length`
| 3933 | `56` |  | `capacity += Handle.Length; // Handle`
| 3933 | `57` |  | `capacity += 8; // ServerFileOffset length`
| 3933 | `58` |  | `capacity += 4; // Data length`
| 3933 | `59` |  | `capacity += Length; // Data`
| 3933 | `60` |  | `return capacity;`
| 3933 | `61` |  | `}`
|  | `62` |  | `}`
|  | `63` |  | ``
|  | `64` |  | `public SftpWriteRequest(uint protocolVersion,`
|  | `65` |  | `uint requestId,`
|  | `66` |  | `byte[] handle,`
|  | `67` |  | `ulong serverFileOffset,`
|  | `68` |  | `byte[] data,`
|  | `69` |  | `int offset,`
|  | `70` |  | `int length,`
|  | `71` |  | `Action<SftpStatusResponse> statusAction)`
| 3939 | `72` |  | `: base(protocolVersion, requestId, statusAction)`
| 3939 | `73` |  | `{`
| 3939 | `74` |  | `Handle = handle;`
| 3939 | `75` |  | `ServerFileOffset = serverFileOffset;`
| 3939 | `76` |  | `Data = data;`
| 3939 | `77` |  | `Offset = offset;`
| 3939 | `78` |  | `Length = length;`
| 3939 | `79` |  | `}`
|  | `80` |  | ``
|  | `81` |  | `protected override void LoadData()`
| 0 | `82` |  | `{`
| 0 | `83` |  | `base.LoadData();`
|  | `84` |  | ``
| 0 | `85` |  | `Handle = ReadBinary();`
| 0 | `86` |  | `ServerFileOffset = ReadUInt64();`
| 0 | `87` |  | `Data = ReadBinary();`
| 0 | `88` |  | `Offset = 0;`
| 0 | `89` |  | `Length = Data.Length;`
| 0 | `90` |  | `}`
|  | `91` |  | ``
|  | `92` |  | `protected override void SaveData()`
| 3933 | `93` |  | `{`
| 3933 | `94` |  | `base.SaveData();`
|  | `95` |  | ``
| 3933 | `96` |  | `WriteBinaryString(Handle);`
| 3933 | `97` |  | `Write(ServerFileOffset);`
| 3933 | `98` |  | `WriteBinary(Data, Offset, Length);`
| 3933 | `99` |  | `}`
|  | `100` |  | `}`
|  | `101` |  | `}`

# Methods/Properties

get_SftpMessageType()
get_Handle()
get_ServerFileOffset()
get_Data()
get_Offset()
get_Length()
get_BufferCapacity()
.ctor(System.UInt32,System.UInt32,System.Byte[],System.UInt64,System.Byte[],System.Int32,System.Int32,System.Action`1<Renci.SshNet.Sftp.Responses.SftpStatusResponse>)
LoadData()
SaveData()