示例#1
0
        void ProcessFile(object sender, ScanEventArgs e)
        {
            if ((events_ != null) && (events_.ProcessFile != null))
            {
                events_.ProcessFile(sender, e);
            }

            if (e.ContinueRunning)
            {
                try {
                    // The open below is equivalent to OpenRead which gaurantees that if opened the
                    // file will not be changed by subsequent openers, but precludes opening in some cases
                    // were it could succeed.
                    using (FileStream stream = File.Open(e.Name, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        ZipEntry entry = entryFactory_.MakeFileEntry(e.Name);
                        outputStream_.PutNextEntry(entry);
                        AddFileContents(e.Name, stream);
                    }
                }
                catch (Exception ex) {
                    if (events_ != null)
                    {
                        continueRunning_ = events_.OnFileFailure(e.Name, ex);
                    }
                    else
                    {
                        continueRunning_ = false;
                        throw;
                    }
                }
            }
        }