[This is preliminary documentation and is subject to change.]
Replaces given ammount of bytes in Stream with another amount of bytes
Namespace: Tools.IOtAssembly: Tools (in Tools.dll) Version: 1.5.3.38916 (1.5.3.38916)
Syntax
| C# |
|---|
public static void InsertInto( this Stream Stream, int Position, int BytesToReplace, byte[] Data, long Offset, long Count, int Chunk ) |
| Visual Basic |
|---|
<ExtensionAttribute> _ Public Shared Sub InsertInto ( _ Stream As Stream, _ Position As Integer, _ BytesToReplace As Integer, _ Data As Byte(), _ Offset As Long, _ Count As Long, _ Chunk As Integer _ ) |
| Visual C++ |
|---|
[ExtensionAttribute] public: static void InsertInto( Stream^ Stream, int Position, int BytesToReplace, array<unsigned char>^ Data, long long Offset, long long Count, int Chunk ) |
| F# |
|---|
static member InsertInto : Stream:Stream * Position:int * BytesToReplace:int * Data:byte[] * Offset:int64 * Count:int64 * Chunk:int -> unit |
| JScript |
|---|
public static function InsertInto( Stream : Stream, Position : int, BytesToReplace : int, Data : byte[], Offset : long, Count : long, Chunk : int ) |
Parameters
- Stream
- Type: System.IO..::..Stream
Stream to perform operation on. It must support seking, reading and writing
- Position
- Type: System..::..Int32
Position where bytes to be replaced starts
- BytesToReplace
- Type: System..::..Int32
Number of bytes currently in stream to be replaced (can be 0)
- Data
- Type: array<System..::..Byte>[]()[][]
Bytes to replace old bytes with
- Offset
- Type: System..::..Int64
Offset in Data to start inserting from
- Count
- Type: System..::..Int64
Number of bytes from Data to use
- Chunk
- Type: System..::..Int32
when data are moved from one part of stream to another they are moved in chunks. This defines size of chunk in bytes. Befault is 1024.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type Stream. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Remarks
If Data's lenght does not match BytesToReplace the stream is shortened or enlarged and data after replaced block are moved as necessary
Exceptions
| Exception | Condition |
|---|---|
| System.IO..::..IOException | An IO error occurs |
| System..::..ObjectDisposedException | Stream is closed |
| System..::..NotSupportedException | Stream does not support seeking -or- Stream does not support writing -or- Stream does not suport reading |
| System..::..ArgumentNullException | Stream is null -or- Data is null |
| System..::..ArgumentOutOfRangeException | Position is not within range <0; Stream.Length) -or- BytesToReplace is not within range <0; Stream.Lenght - Position - or- Chunk is not positive -or- Offset or Count is negative |
| System..::..ArgumentException | Sum of Offset and Count is greater than length of Data |
See Also
Version History
1.5.3
- (Nightly) Fix: ArgumentOutOfRangeException may be thrown when BytesToReplace < Count.
- Fix: ArgumentException thrown when BytesToReplace >= Count (fixed - the exception is no longer thrown).