C# DeflateStream CanSeek

Description

DeflateStream CanSeek Gets a value indicating whether the stream supports seeking.

Syntax

DeflateStream.CanSeek has the following syntax.


public override bool CanSeek { get; }

Example


using System;/*w  w  w  . ja v  a 2 s. c  o m*/
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;

class Program
{
    static void Main(string[] args)
    {
        string directoryPath = @"c:\users\public\reports";
        DirectoryInfo directorySelected = new DirectoryInfo(directoryPath);

        foreach (FileInfo fileToCompress in directorySelected.EnumerateFiles())
        {
            Compress(fileToCompress);
        }
    }

    public static void Compress(FileInfo fileToCompress)
    {
        using (FileStream originalFileStream = fileToCompress.OpenRead())
        {
            using (FileStream compressedFileStream = File.Create(fileToCompress.FullName + ".cmp"))
            {
                using (DeflateStream compressionStream = new DeflateStream(compressedFileStream, CompressionMode.Compress))
                {
                    Console.WriteLine(compressionStream.CanSeek);
                }
            }
        }
    }
}




















Home »
  C# Tutorial »
    System.IO.Compression »




DeflateStream
GZipStream
ZipArchive
ZipArchiveEntry
ZipFile
ZipFileExtensions