FileRecordSequence.BaseSequenceNumber 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得目前 中第一個有效記錄的序號。
public:
property System::IO::Log::SequenceNumber BaseSequenceNumber { System::IO::Log::SequenceNumber get(); };
public System.IO.Log.SequenceNumber BaseSequenceNumber { get; }
member this.BaseSequenceNumber : System.IO.Log.SequenceNumber
Public ReadOnly Property BaseSequenceNumber As SequenceNumber
屬性值
對應至 FileRecordSequence 中之有效記錄的最小序號。
實作
例外狀況
已在處置序列之後存取此屬性。
範例
下列範例說明在迴圈中使用 BaseSequenceNumber:
// Read the records added to the log.
public void ReadRecords()
{
Encoding enc = Encoding.Unicode;
Console.WriteLine();
Console.WriteLine("Reading Log Records...");
try
{
foreach (LogRecord record in this.sequence.ReadLogRecords(this.sequence.BaseSequenceNumber, LogRecordEnumeratorType.Next))
{
byte[] data = new byte[record.Data.Length];
record.Data.Read(data, 0, (int)record.Data.Length);
string mystr = enc.GetString(data);
Console.WriteLine(" {0}", mystr);
}
}
catch (Exception e)
{
Console.WriteLine("Exception {0} {1}", e.GetType(), e.Message);
}
Console.WriteLine();
}
' Read the records added to the log.
Public Sub ReadRecords()
Dim enc As Encoding = Encoding.Unicode
Console.WriteLine()
Console.WriteLine("Reading Log Records...")
Try
For Each record In Me.sequence.ReadLogRecords(Me.sequence.BaseSequenceNumber, LogRecordEnumeratorType.Next)
Dim data(record.Data.Length - 1) As Byte
record.Data.Read(data, 0, CInt(Fix(record.Data.Length)))
Dim mystr As String = enc.GetString(data)
Console.WriteLine(" {0}", mystr)
Next record
Catch e As Exception
Console.WriteLine("Exception {0} {1}", e.GetType(), e.Message)
End Try
Console.WriteLine()
End Sub
備註
有效的序號會大於或等於 BaseSequenceNumber,而且小於 LastSequenceNumber。 其他所有序號全都無效。
這個屬性的值可藉由呼叫 WriteRestartArea 或 AdvanceBaseSequenceNumber 方法加以變更。