Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
LogArchiveSnapshot Class

LogArchiveSnapshot Class

Represents a snapshot of the LogStore instance that can be used to generate an archive.


Namespace:  System.IO.Log
Assembly:  System.IO.Log (in System.IO.Log.dll)

public sealed class LogArchiveSnapshot

The LogArchiveSnapshot type exposes the following members.

Public propertyArchiveRegionsGets an enumerable collection of FileRegion instances containing the actual archival data.
Public propertyArchiveTailGets the sequence number of the LogStore archive tail at the time the snapshot was taken.
Public propertyBaseSequenceNumberGets the base sequence number of the LogStore at the time the snapshot was taken.
Public propertyLastSequenceNumberGets the last sequence number of the LogStore at the time the snapshot was taken.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

A LogArchiveSnapshot object contains the information necessary to generate a consistent backup of the data in a LogStore. The actual data is contained in the enumerable collection of FileRegion objects returned by the ArchiveRegions property. Each FileRegion instance represents a sequence of bytes in a file that must be archived.

The ArchiveTail, BaseSequenceNumber, and LastSequenceNumber properties are for informational purposes only. They can be recorded along with the archive data to provide optional information, but are not required to restore the data.

The following example shows how to use the LogArchiveSnapshot class to archive a LogStore to an XML document.

class LogBackup
    static void ArchiveToXML(LogStore logStore, string fileName) 
        LogArchiveSnapshot snapshot = logStore.CreateLogArchiveSnapshot();

        XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.ASCII);

        foreach(FileRegion region in snapshot.ArchiveRegions) 
            writer.WriteElementString("path", region.Path); 
            writer.WriteElementString("length", region.FileLength.ToString()); 
            writer.WriteElementString("offset", region.Offset.ToString()); 
            using(Stream dataStream = region.GetStream()) 
                byte[] data = new byte[dataStream.Length]; 
                dataStream.Read(data, 0, data.Length); 
                writer.WriteElementString("data", Convert.ToBase64String(data)); 

    static void RestoreFromXML(string fileName) 
        using(XmlTextReader reader = new XmlTextReader(fileName)) 
                string path = reader.ReadElementString("path"); 
                long length = Int64.Parse(reader.ReadElementString("length")); 
                long offset = Int64.Parse(reader.ReadElementString("offset")); 
                string dataString = reader.ReadElementString("data"); 
                byte[] data = Convert.FromBase64String(dataString); 
                FileStream fileStream;
                using(fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) 
                    fileStream.Position = offset; fileStream.Write(data, 0, data.Length); 

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft