ToBase64Transform.TransformBlock(Byte[], Int32, Int32, Byte[], Int32) 方法

定義

將輸入位元組陣列的指定區域轉換為 Base 64,並且將結果複製至輸出位元組陣列的指定區域。

public:
 virtual int TransformBlock(cli::array <System::Byte> ^ inputBuffer, int inputOffset, int inputCount, cli::array <System::Byte> ^ outputBuffer, int outputOffset);
public int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset);
abstract member TransformBlock : byte[] * int * int * byte[] * int -> int
override this.TransformBlock : byte[] * int * int * byte[] * int -> int
Public Function TransformBlock (inputBuffer As Byte(), inputOffset As Integer, inputCount As Integer, outputBuffer As Byte(), outputOffset As Integer) As Integer

參數

inputBuffer
Byte[]

要計算成 Base 64 的輸入。

inputOffset
Int32

輸入位元組陣列中的座標,從此處開始使用資料。

inputCount
Int32

輸入位元組陣列中要用作資料的位元組數目。

outputBuffer
Byte[]

要將結果寫入至的輸出。

outputOffset
Int32

輸出位元組陣列中的座標,從此處開始寫入資料。

傳回

Int32

寫入的位元組數目。

實作

例外狀況

目前的 ToBase64Transform 物件已經處置 (Dispose)。

資料大小無效。

inputBuffer 參數包含無效的位移長度。

-或- inputCount 參數包含無效的值。

inputBuffer 參數為 null

inputBuffer 參數需要非負數的數字。

範例

下列程式碼範例示範如何呼叫 TransformBlock 方法來逐一查看 inputBytesblockSize 轉換。 此程式碼範例是提供給 類別之較大範例的 ToBase64Transform 一部分。

int inputBlockSize = base64Transform->InputBlockSize;
while ( inputBytes->Length - inputOffset > inputBlockSize )
{
   base64Transform->TransformBlock(
      inputBytes,
      inputOffset,
      inputBytes->Length - inputOffset,
      outputBytes,
      0 );

   inputOffset += base64Transform->InputBlockSize;
   outputFileStream->Write(
      outputBytes,
      0,
      base64Transform->OutputBlockSize );
}
int inputBlockSize = base64Transform.InputBlockSize;

while(inputBytes.Length - inputOffset > inputBlockSize)
{
    base64Transform.TransformBlock(
        inputBytes,
        inputOffset,
        inputBytes.Length - inputOffset,
        outputBytes,
        0);

    inputOffset += base64Transform.InputBlockSize;
    outputFileStream.Write(
        outputBytes, 
        0, 
        base64Transform.OutputBlockSize);
}
Dim inputBlockSize As Integer = base64Transform.InputBlockSize

While (inputBytes.Length - inputOffset > inputBlockSize)
    base64Transform.TransformBlock( _
        inputBytes, _
        inputOffset, _
        inputBytes.Length - inputOffset, _
        outputBytes, _
        0)

    inputOffset += base64Transform.InputBlockSize
    outputFileStream.Write(outputBytes, _
        0, _
        base64Transform.OutputBlockSize)
End While

備註

類別 ToBase64Transform 是區塊演算法,可處理 3 個位元組的輸入區塊,並建立 4 個位元組的輸出區塊。 方法 TransformBlock 會將 24 位的輸入區塊轉換成 32 位的字元資料。 您必須維護 3 個位元組的輸入界限到 4 個位元組的輸出界限,才能符合區塊轉換。

適用於

另請參閱