本文整理匯總了VB.NET中System.IO.Log.LogArchiveSnapshot.ArchiveRegions屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET LogArchiveSnapshot.ArchiveRegions屬性的具體用法?VB.NET LogArchiveSnapshot.ArchiveRegions怎麽用?VB.NET LogArchiveSnapshot.ArchiveRegions使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.IO.Log.LogArchiveSnapshot
的用法示例。
在下文中一共展示了LogArchiveSnapshot.ArchiveRegions屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: LogBackup
Friend Class LogBackup
Private Shared Sub ArchiveToXML(ByVal logStore As LogStore, ByVal fileName As String)
Dim snapshot As LogArchiveSnapshot = logStore.CreateLogArchiveSnapshot()
Dim writer As New XmlTextWriter(fileName, Encoding.ASCII)
writer.WriteStartElement("logArchive")
For Each region As FileRegion In snapshot.ArchiveRegions
writer.WriteStartElement("fileRegion")
writer.WriteElementString("path", region.Path)
writer.WriteElementString("length", region.FileLength.ToString())
writer.WriteElementString("offset", region.Offset.ToString())
Using dataStream As Stream = region.GetStream()
Dim data(dataStream.Length - 1) As Byte
dataStream.Read(data, 0, data.Length)
writer.WriteElementString("data", Convert.ToBase64String(data))
End Using
writer.WriteEndElement()
Next region
writer.WriteEndElement()
writer.Close()
logStore.SetArchiveTail(snapshot.LastSequenceNumber)
End Sub
Private Shared Sub RestoreFromXML(ByVal fileName As String)
Using reader As New XmlTextReader(fileName)
reader.ReadStartElement("logArchive")
Do While reader.IsStartElement()
Dim path = reader.ReadElementString("path")
Dim length = Int64.Parse(reader.ReadElementString("length"))
Dim offset = Int64.Parse(reader.ReadElementString("offset"))
Dim dataString = reader.ReadElementString("data")
Dim data() = Convert.FromBase64String(dataString)
Dim fileStream As FileStream
fileStream = New FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)
Using fileStream
fileStream.SetLength(length)
fileStream.Position = offset
fileStream.Write(data, 0, data.Length)
End Using
Loop
reader.ReadEndElement()
End Using
End Sub
End Class