Ionic.Zip.ZipSegmentedStream.ForUpdate C# (CSharp) Méthode

ForUpdate() public static méthode

Sort-of like a factory method, ForUpdate is used only when the application needs to update the zip entry metadata for a segmented zip file, when the starting segment is earlier than the ending segment, for a particular entry.

The update is always contiguous, never rolls over. As a result, this method doesn't need to return a ZSS; it can simply return a FileStream. That's why it's "sort of" like a Factory method.

Caller must Close/Dispose the stream object returned by this method.

public static ForUpdate ( string name, uint diskNumber ) : Stream
name string
diskNumber uint
Résultat Stream
        public static Stream ForUpdate(string name, uint diskNumber)
        {

            string fname =
                String.Format("{0}.z{1:D2}",
                                 Path.Combine(Path.GetDirectoryName(name),
                                              Path.GetFileNameWithoutExtension(name)),
                                 diskNumber + 1);

            // Console.WriteLine("ZSS: ForUpdate ({0})",
            //                   Path.GetFileName(fname));

            // This class assumes that the update will not expand the
            // size of the segment. Update is used only for an in-place
            // update of zip metadata. It never will try to write beyond
            // the end of a segment.

            return File.Open(fname,
                             FileMode.Open,
                             FileAccess.ReadWrite,
                             FileShare.None);
        }