ICSharpCode.SharpZipLib.Zip.ZipEntry.IsCompressionMethodSupported C# (CSharp) Method

IsCompressionMethodSupported() public method

Test entry to see if data can be extracted.
public IsCompressionMethodSupported ( ) : bool
return bool
        public bool IsCompressionMethodSupported()
        {
            return IsCompressionMethodSupported(CompressionMethod);
        }

Same methods

ZipEntry::IsCompressionMethodSupported ( CompressionMethod method ) : bool

Usage Example

Example #1
0
        private void ExtractEntry(ZipEntry entry)
        {
            bool   doExtraction = entry.IsCompressionMethodSupported();
            string targetName   = entry.Name;

            if (doExtraction)
            {
                if (entry.IsFile)
                {
                    targetName = extractNameTransform_.TransformFile(targetName);
                }
                else if (entry.IsDirectory)
                {
                    targetName = extractNameTransform_.TransformDirectory(targetName);
                }

                doExtraction = !((targetName == null) || (targetName.Length == 0));
            }

            // TODO: Fire delegate/throw exception were compression method not supported, or name is invalid?

            string dirName = null;

            if (doExtraction)
            {
                if (entry.IsDirectory)
                {
                    dirName = targetName;
                }
                else
                {
                    dirName = Path.GetDirectoryName(Path.GetFullPath(targetName));
                }
            }

            if (doExtraction && !Directory.Exists(dirName))
            {
                if (!entry.IsDirectory)
                {
                    try
                    {
                        Directory.CreateDirectory(dirName);
                    }
                    catch (Exception)
                    {
                        doExtraction     = false;
                        continueRunning_ = false;
                        throw;
                    }
                }
            }

            if (doExtraction && entry.IsFile)
            {
                ExtractFileEntry(entry, targetName);
            }
        }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipEntry::IsCompressionMethodSupported