ICSharpCode.SharpZipLib.Zip.FastZipEvents.OnProcessFile C# (CSharp) Method

OnProcessFile() public method

Fires the ProcessFile delegate.
public OnProcessFile ( string file ) : bool
file string The file being processed.
return bool
        public bool OnProcessFile(string file)
        {
            bool result = true;
            ProcessFileHandler handler = ProcessFile;

            if (handler != null) {
                var args = new ScanEventArgs(file);
                handler(this, args);
                result = args.ContinueRunning;
            }
            return result;
        }

Usage Example

Example #1
0
        private void ExtractFileEntry(ZipEntry entry, string targetName)
        {
            bool flag = true;

            if (overwrite_ != Overwrite.Always && File.Exists(targetName))
            {
                flag = (overwrite_ == Overwrite.Prompt && confirmDelegate_ != null && confirmDelegate_(targetName));
            }
            if (flag)
            {
                if (events_ != null)
                {
                    continueRunning_ = events_.OnProcessFile(entry.Name);
                }
                if (continueRunning_)
                {
                    try
                    {
                        using (FileStream destination = File.Create(targetName))
                        {
                            if (buffer_ == null)
                            {
                                buffer_ = new byte[4096];
                            }
                            if (events_ != null && events_.Progress != null)
                            {
                                StreamUtils.Copy(zipFile_.GetInputStream(entry), destination, buffer_, events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size);
                            }
                            else
                            {
                                StreamUtils.Copy(zipFile_.GetInputStream(entry), destination, buffer_);
                            }
                            if (events_ != null)
                            {
                                continueRunning_ = events_.OnCompletedFile(entry.Name);
                            }
                        }
                        if (restoreDateTimeOnExtract_)
                        {
                            File.SetLastWriteTime(targetName, entry.DateTime);
                        }
                        if (RestoreAttributesOnExtract && entry.IsDOSEntry && entry.ExternalFileAttributes != -1)
                        {
                            FileAttributes externalFileAttributes = (FileAttributes)entry.ExternalFileAttributes;
                            externalFileAttributes &= (FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.Archive | FileAttributes.Normal);
                            File.SetAttributes(targetName, externalFileAttributes);
                        }
                    }
                    catch (Exception e)
                    {
                        if (events_ == null)
                        {
                            continueRunning_ = false;
                            throw;
                        }
                        continueRunning_ = events_.OnFileFailure(targetName, e);
                    }
                }
            }
        }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.FastZipEvents::OnProcessFile