Events.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. // Events.cs
  2. // ------------------------------------------------------------------
  3. //
  4. // Copyright (c) 2006, 2007, 2008, 2009 Dino Chiesa and Microsoft Corporation.
  5. // All rights reserved.
  6. //
  7. // This code module is part of DotNetZip, a zipfile class library.
  8. //
  9. // ------------------------------------------------------------------
  10. //
  11. // This code is licensed under the Microsoft Public License.
  12. // See the file License.txt for the license details.
  13. // More info on: http://dotnetzip.codeplex.com
  14. //
  15. // ------------------------------------------------------------------
  16. //
  17. // last saved (in emacs):
  18. // Time-stamp: <2011-August-06 12:26:24>
  19. //
  20. // ------------------------------------------------------------------
  21. //
  22. // This module defines events used by the ZipFile class.
  23. //
  24. //
  25. using System;
  26. using System.Collections.Generic;
  27. using System.Text;
  28. namespace Ionic.Zip
  29. {
  30. /// <summary>
  31. /// Delegate in which the application writes the <c>ZipEntry</c> content for the named entry.
  32. /// </summary>
  33. ///
  34. /// <param name="entryName">The name of the entry that must be written.</param>
  35. /// <param name="stream">The stream to which the entry data should be written.</param>
  36. ///
  37. /// <remarks>
  38. /// When you add an entry and specify a <c>WriteDelegate</c>, via <see
  39. /// cref="Ionic.Zip.ZipFile.AddEntry(string, WriteDelegate)"/>, the application
  40. /// code provides the logic that writes the entry data directly into the zip file.
  41. /// </remarks>
  42. ///
  43. /// <example>
  44. ///
  45. /// This example shows how to define a WriteDelegate that obtains a DataSet, and then
  46. /// writes the XML for the DataSet into the zip archive. There's no need to
  47. /// save the XML to a disk file first.
  48. ///
  49. /// <code lang="C#">
  50. /// private void WriteEntry (String filename, Stream output)
  51. /// {
  52. /// DataSet ds1 = ObtainDataSet();
  53. /// ds1.WriteXml(output);
  54. /// }
  55. ///
  56. /// private void Run()
  57. /// {
  58. /// using (var zip = new ZipFile())
  59. /// {
  60. /// zip.AddEntry(zipEntryName, WriteEntry);
  61. /// zip.Save(zipFileName);
  62. /// }
  63. /// }
  64. /// </code>
  65. ///
  66. /// <code lang="vb">
  67. /// Private Sub WriteEntry (ByVal filename As String, ByVal output As Stream)
  68. /// DataSet ds1 = ObtainDataSet()
  69. /// ds1.WriteXml(stream)
  70. /// End Sub
  71. ///
  72. /// Public Sub Run()
  73. /// Using zip = New ZipFile
  74. /// zip.AddEntry(zipEntryName, New WriteDelegate(AddressOf WriteEntry))
  75. /// zip.Save(zipFileName)
  76. /// End Using
  77. /// End Sub
  78. /// </code>
  79. /// </example>
  80. /// <seealso cref="Ionic.Zip.ZipFile.AddEntry(string, WriteDelegate)"/>
  81. public delegate void WriteDelegate(string entryName, System.IO.Stream stream);
  82. /// <summary>
  83. /// Delegate in which the application opens the stream, just-in-time, for the named entry.
  84. /// </summary>
  85. ///
  86. /// <param name="entryName">
  87. /// The name of the ZipEntry that the application should open the stream for.
  88. /// </param>
  89. ///
  90. /// <remarks>
  91. /// When you add an entry via <see cref="Ionic.Zip.ZipFile.AddEntry(string,
  92. /// OpenDelegate, CloseDelegate)"/>, the application code provides the logic that
  93. /// opens and closes the stream for the given ZipEntry.
  94. /// </remarks>
  95. ///
  96. /// <seealso cref="Ionic.Zip.ZipFile.AddEntry(string, OpenDelegate, CloseDelegate)"/>
  97. public delegate System.IO.Stream OpenDelegate(string entryName);
  98. /// <summary>
  99. /// Delegate in which the application closes the stream, just-in-time, for the named entry.
  100. /// </summary>
  101. ///
  102. /// <param name="entryName">
  103. /// The name of the ZipEntry that the application should close the stream for.
  104. /// </param>
  105. ///
  106. /// <param name="stream">The stream to be closed.</param>
  107. ///
  108. /// <remarks>
  109. /// When you add an entry via <see cref="Ionic.Zip.ZipFile.AddEntry(string,
  110. /// OpenDelegate, CloseDelegate)"/>, the application code provides the logic that
  111. /// opens and closes the stream for the given ZipEntry.
  112. /// </remarks>
  113. ///
  114. /// <seealso cref="Ionic.Zip.ZipFile.AddEntry(string, OpenDelegate, CloseDelegate)"/>
  115. public delegate void CloseDelegate(string entryName, System.IO.Stream stream);
  116. /// <summary>
  117. /// Delegate for the callback by which the application tells the
  118. /// library the CompressionLevel to use for a file.
  119. /// </summary>
  120. ///
  121. /// <remarks>
  122. /// <para>
  123. /// Using this callback, the application can, for example, specify that
  124. /// previously-compressed files (.mp3, .png, .docx, etc) should use a
  125. /// <c>CompressionLevel</c> of <c>None</c>, or can set the compression level based
  126. /// on any other factor.
  127. /// </para>
  128. /// </remarks>
  129. /// <seealso cref="Ionic.Zip.ZipFile.SetCompression"/>
  130. public delegate Ionic.Zlib.CompressionLevel SetCompressionCallback(string localFileName, string fileNameInArchive);
  131. /// <summary>
  132. /// In an EventArgs type, indicates which sort of progress event is being
  133. /// reported.
  134. /// </summary>
  135. /// <remarks>
  136. /// There are events for reading, events for saving, and events for
  137. /// extracting. This enumeration allows a single EventArgs type to be sued to
  138. /// describe one of multiple subevents. For example, a SaveProgress event is
  139. /// invoked before, after, and during the saving of a single entry. The value
  140. /// of an enum with this type, specifies which event is being triggered. The
  141. /// same applies to Extraction, Reading and Adding events.
  142. /// </remarks>
  143. public enum ZipProgressEventType
  144. {
  145. /// <summary>
  146. /// Indicates that a Add() operation has started.
  147. /// </summary>
  148. Adding_Started,
  149. /// <summary>
  150. /// Indicates that an individual entry in the archive has been added.
  151. /// </summary>
  152. Adding_AfterAddEntry,
  153. /// <summary>
  154. /// Indicates that a Add() operation has completed.
  155. /// </summary>
  156. Adding_Completed,
  157. /// <summary>
  158. /// Indicates that a Read() operation has started.
  159. /// </summary>
  160. Reading_Started,
  161. /// <summary>
  162. /// Indicates that an individual entry in the archive is about to be read.
  163. /// </summary>
  164. Reading_BeforeReadEntry,
  165. /// <summary>
  166. /// Indicates that an individual entry in the archive has just been read.
  167. /// </summary>
  168. Reading_AfterReadEntry,
  169. /// <summary>
  170. /// Indicates that a Read() operation has completed.
  171. /// </summary>
  172. Reading_Completed,
  173. /// <summary>
  174. /// The given event reports the number of bytes read so far
  175. /// during a Read() operation.
  176. /// </summary>
  177. Reading_ArchiveBytesRead,
  178. /// <summary>
  179. /// Indicates that a Save() operation has started.
  180. /// </summary>
  181. Saving_Started,
  182. /// <summary>
  183. /// Indicates that an individual entry in the archive is about to be written.
  184. /// </summary>
  185. Saving_BeforeWriteEntry,
  186. /// <summary>
  187. /// Indicates that an individual entry in the archive has just been saved.
  188. /// </summary>
  189. Saving_AfterWriteEntry,
  190. /// <summary>
  191. /// Indicates that a Save() operation has completed.
  192. /// </summary>
  193. Saving_Completed,
  194. /// <summary>
  195. /// Indicates that the zip archive has been created in a
  196. /// temporary location during a Save() operation.
  197. /// </summary>
  198. Saving_AfterSaveTempArchive,
  199. /// <summary>
  200. /// Indicates that the temporary file is about to be renamed to the final archive
  201. /// name during a Save() operation.
  202. /// </summary>
  203. Saving_BeforeRenameTempArchive,
  204. /// <summary>
  205. /// Indicates that the temporary file is has just been renamed to the final archive
  206. /// name during a Save() operation.
  207. /// </summary>
  208. Saving_AfterRenameTempArchive,
  209. /// <summary>
  210. /// Indicates that the self-extracting archive has been compiled
  211. /// during a Save() operation.
  212. /// </summary>
  213. Saving_AfterCompileSelfExtractor,
  214. /// <summary>
  215. /// The given event is reporting the number of source bytes that have run through the compressor so far
  216. /// during a Save() operation.
  217. /// </summary>
  218. Saving_EntryBytesRead,
  219. /// <summary>
  220. /// Indicates that an entry is about to be extracted.
  221. /// </summary>
  222. Extracting_BeforeExtractEntry,
  223. /// <summary>
  224. /// Indicates that an entry has just been extracted.
  225. /// </summary>
  226. Extracting_AfterExtractEntry,
  227. /// <summary>
  228. /// Indicates that extraction of an entry would overwrite an existing
  229. /// filesystem file. You must use
  230. /// <see cref="ExtractExistingFileAction.InvokeExtractProgressEvent">
  231. /// ExtractExistingFileAction.InvokeExtractProgressEvent</see> in the call
  232. /// to <c>ZipEntry.Extract()</c> in order to receive this event.
  233. /// </summary>
  234. Extracting_ExtractEntryWouldOverwrite,
  235. /// <summary>
  236. /// The given event is reporting the number of bytes written so far for
  237. /// the current entry during an Extract() operation.
  238. /// </summary>
  239. Extracting_EntryBytesWritten,
  240. /// <summary>
  241. /// Indicates that an ExtractAll operation is about to begin.
  242. /// </summary>
  243. Extracting_BeforeExtractAll,
  244. /// <summary>
  245. /// Indicates that an ExtractAll operation has completed.
  246. /// </summary>
  247. Extracting_AfterExtractAll,
  248. /// <summary>
  249. /// Indicates that an error has occurred while saving a zip file.
  250. /// This generally means the file cannot be opened, because it has been
  251. /// removed, or because it is locked by another process. It can also
  252. /// mean that the file cannot be Read, because of a range lock conflict.
  253. /// </summary>
  254. Error_Saving,
  255. }
  256. /// <summary>
  257. /// Provides information about the progress of a save, read, or extract operation.
  258. /// This is a base class; you will probably use one of the classes derived from this one.
  259. /// </summary>
  260. public class ZipProgressEventArgs : EventArgs
  261. {
  262. private int _entriesTotal;
  263. private bool _cancel;
  264. private ZipEntry _latestEntry;
  265. private ZipProgressEventType _flavor;
  266. private String _archiveName;
  267. private Int64 _bytesTransferred;
  268. private Int64 _totalBytesToTransfer;
  269. internal ZipProgressEventArgs() { }
  270. internal ZipProgressEventArgs(string archiveName, ZipProgressEventType flavor)
  271. {
  272. this._archiveName = archiveName;
  273. this._flavor = flavor;
  274. }
  275. /// <summary>
  276. /// The total number of entries to be saved or extracted.
  277. /// </summary>
  278. public int EntriesTotal
  279. {
  280. get { return _entriesTotal; }
  281. set { _entriesTotal = value; }
  282. }
  283. /// <summary>
  284. /// The name of the last entry saved or extracted.
  285. /// </summary>
  286. public ZipEntry CurrentEntry
  287. {
  288. get { return _latestEntry; }
  289. set { _latestEntry = value; }
  290. }
  291. /// <summary>
  292. /// In an event handler, set this to cancel the save or extract
  293. /// operation that is in progress.
  294. /// </summary>
  295. public bool Cancel
  296. {
  297. get { return _cancel; }
  298. set { _cancel = _cancel || value; }
  299. }
  300. /// <summary>
  301. /// The type of event being reported.
  302. /// </summary>
  303. public ZipProgressEventType EventType
  304. {
  305. get { return _flavor; }
  306. set { _flavor = value; }
  307. }
  308. /// <summary>
  309. /// Returns the archive name associated to this event.
  310. /// </summary>
  311. public String ArchiveName
  312. {
  313. get { return _archiveName; }
  314. set { _archiveName = value; }
  315. }
  316. /// <summary>
  317. /// The number of bytes read or written so far for this entry.
  318. /// </summary>
  319. public Int64 BytesTransferred
  320. {
  321. get { return _bytesTransferred; }
  322. set { _bytesTransferred = value; }
  323. }
  324. /// <summary>
  325. /// Total number of bytes that will be read or written for this entry.
  326. /// This number will be -1 if the value cannot be determined.
  327. /// </summary>
  328. public Int64 TotalBytesToTransfer
  329. {
  330. get { return _totalBytesToTransfer; }
  331. set { _totalBytesToTransfer = value; }
  332. }
  333. }
  334. /// <summary>
  335. /// Provides information about the progress of a Read operation.
  336. /// </summary>
  337. public class ReadProgressEventArgs : ZipProgressEventArgs
  338. {
  339. internal ReadProgressEventArgs() { }
  340. private ReadProgressEventArgs(string archiveName, ZipProgressEventType flavor)
  341. : base(archiveName, flavor)
  342. { }
  343. internal static ReadProgressEventArgs Before(string archiveName, int entriesTotal)
  344. {
  345. var x = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_BeforeReadEntry);
  346. x.EntriesTotal = entriesTotal;
  347. return x;
  348. }
  349. internal static ReadProgressEventArgs After(string archiveName, ZipEntry entry, int entriesTotal)
  350. {
  351. var x = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_AfterReadEntry);
  352. x.EntriesTotal = entriesTotal;
  353. x.CurrentEntry = entry;
  354. return x;
  355. }
  356. internal static ReadProgressEventArgs Started(string archiveName)
  357. {
  358. var x = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_Started);
  359. return x;
  360. }
  361. internal static ReadProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, Int64 bytesXferred, Int64 totalBytes)
  362. {
  363. var x = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_ArchiveBytesRead);
  364. x.CurrentEntry = entry;
  365. x.BytesTransferred = bytesXferred;
  366. x.TotalBytesToTransfer = totalBytes;
  367. return x;
  368. }
  369. internal static ReadProgressEventArgs Completed(string archiveName)
  370. {
  371. var x = new ReadProgressEventArgs(archiveName, ZipProgressEventType.Reading_Completed);
  372. return x;
  373. }
  374. }
  375. /// <summary>
  376. /// Provides information about the progress of a Add operation.
  377. /// </summary>
  378. public class AddProgressEventArgs : ZipProgressEventArgs
  379. {
  380. internal AddProgressEventArgs() { }
  381. private AddProgressEventArgs(string archiveName, ZipProgressEventType flavor)
  382. : base(archiveName, flavor)
  383. { }
  384. internal static AddProgressEventArgs AfterEntry(string archiveName, ZipEntry entry, int entriesTotal)
  385. {
  386. var x = new AddProgressEventArgs(archiveName, ZipProgressEventType.Adding_AfterAddEntry);
  387. x.EntriesTotal = entriesTotal;
  388. x.CurrentEntry = entry;
  389. return x;
  390. }
  391. internal static AddProgressEventArgs Started(string archiveName)
  392. {
  393. var x = new AddProgressEventArgs(archiveName, ZipProgressEventType.Adding_Started);
  394. return x;
  395. }
  396. internal static AddProgressEventArgs Completed(string archiveName)
  397. {
  398. var x = new AddProgressEventArgs(archiveName, ZipProgressEventType.Adding_Completed);
  399. return x;
  400. }
  401. }
  402. /// <summary>
  403. /// Provides information about the progress of a save operation.
  404. /// </summary>
  405. public class SaveProgressEventArgs : ZipProgressEventArgs
  406. {
  407. private int _entriesSaved;
  408. /// <summary>
  409. /// Constructor for the SaveProgressEventArgs.
  410. /// </summary>
  411. /// <param name="archiveName">the name of the zip archive.</param>
  412. /// <param name="before">whether this is before saving the entry, or after</param>
  413. /// <param name="entriesTotal">The total number of entries in the zip archive.</param>
  414. /// <param name="entriesSaved">Number of entries that have been saved.</param>
  415. /// <param name="entry">The entry involved in the event.</param>
  416. internal SaveProgressEventArgs(string archiveName, bool before, int entriesTotal, int entriesSaved, ZipEntry entry)
  417. : base(archiveName, (before) ? ZipProgressEventType.Saving_BeforeWriteEntry : ZipProgressEventType.Saving_AfterWriteEntry)
  418. {
  419. this.EntriesTotal = entriesTotal;
  420. this.CurrentEntry = entry;
  421. this._entriesSaved = entriesSaved;
  422. }
  423. internal SaveProgressEventArgs() { }
  424. internal SaveProgressEventArgs(string archiveName, ZipProgressEventType flavor)
  425. : base(archiveName, flavor)
  426. { }
  427. internal static SaveProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, Int64 bytesXferred, Int64 totalBytes)
  428. {
  429. var x = new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_EntryBytesRead);
  430. x.ArchiveName = archiveName;
  431. x.CurrentEntry = entry;
  432. x.BytesTransferred = bytesXferred;
  433. x.TotalBytesToTransfer = totalBytes;
  434. return x;
  435. }
  436. internal static SaveProgressEventArgs Started(string archiveName)
  437. {
  438. var x = new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_Started);
  439. return x;
  440. }
  441. internal static SaveProgressEventArgs Completed(string archiveName)
  442. {
  443. var x = new SaveProgressEventArgs(archiveName, ZipProgressEventType.Saving_Completed);
  444. return x;
  445. }
  446. /// <summary>
  447. /// Number of entries saved so far.
  448. /// </summary>
  449. public int EntriesSaved
  450. {
  451. get { return _entriesSaved; }
  452. }
  453. }
  454. /// <summary>
  455. /// Provides information about the progress of the extract operation.
  456. /// </summary>
  457. public class ExtractProgressEventArgs : ZipProgressEventArgs
  458. {
  459. private int _entriesExtracted;
  460. private string _target;
  461. /// <summary>
  462. /// Constructor for the ExtractProgressEventArgs.
  463. /// </summary>
  464. /// <param name="archiveName">the name of the zip archive.</param>
  465. /// <param name="before">whether this is before saving the entry, or after</param>
  466. /// <param name="entriesTotal">The total number of entries in the zip archive.</param>
  467. /// <param name="entriesExtracted">Number of entries that have been extracted.</param>
  468. /// <param name="entry">The entry involved in the event.</param>
  469. /// <param name="extractLocation">The location to which entries are extracted.</param>
  470. internal ExtractProgressEventArgs(string archiveName, bool before, int entriesTotal, int entriesExtracted, ZipEntry entry, string extractLocation)
  471. : base(archiveName, (before) ? ZipProgressEventType.Extracting_BeforeExtractEntry : ZipProgressEventType.Extracting_AfterExtractEntry)
  472. {
  473. this.EntriesTotal = entriesTotal;
  474. this.CurrentEntry = entry;
  475. this._entriesExtracted = entriesExtracted;
  476. this._target = extractLocation;
  477. }
  478. internal ExtractProgressEventArgs(string archiveName, ZipProgressEventType flavor)
  479. : base(archiveName, flavor)
  480. { }
  481. internal ExtractProgressEventArgs()
  482. { }
  483. internal static ExtractProgressEventArgs BeforeExtractEntry(string archiveName, ZipEntry entry, string extractLocation)
  484. {
  485. var x = new ExtractProgressEventArgs
  486. {
  487. ArchiveName = archiveName,
  488. EventType = ZipProgressEventType.Extracting_BeforeExtractEntry,
  489. CurrentEntry = entry,
  490. _target = extractLocation,
  491. };
  492. return x;
  493. }
  494. internal static ExtractProgressEventArgs ExtractExisting(string archiveName, ZipEntry entry, string extractLocation)
  495. {
  496. var x = new ExtractProgressEventArgs
  497. {
  498. ArchiveName = archiveName,
  499. EventType = ZipProgressEventType.Extracting_ExtractEntryWouldOverwrite,
  500. CurrentEntry = entry,
  501. _target = extractLocation,
  502. };
  503. return x;
  504. }
  505. internal static ExtractProgressEventArgs AfterExtractEntry(string archiveName, ZipEntry entry, string extractLocation)
  506. {
  507. var x = new ExtractProgressEventArgs
  508. {
  509. ArchiveName = archiveName,
  510. EventType = ZipProgressEventType.Extracting_AfterExtractEntry,
  511. CurrentEntry = entry,
  512. _target = extractLocation,
  513. };
  514. return x;
  515. }
  516. internal static ExtractProgressEventArgs ExtractAllStarted(string archiveName, string extractLocation)
  517. {
  518. var x = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_BeforeExtractAll);
  519. x._target = extractLocation;
  520. return x;
  521. }
  522. internal static ExtractProgressEventArgs ExtractAllCompleted(string archiveName, string extractLocation)
  523. {
  524. var x = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_AfterExtractAll);
  525. x._target = extractLocation;
  526. return x;
  527. }
  528. internal static ExtractProgressEventArgs ByteUpdate(string archiveName, ZipEntry entry, Int64 bytesWritten, Int64 totalBytes)
  529. {
  530. var x = new ExtractProgressEventArgs(archiveName, ZipProgressEventType.Extracting_EntryBytesWritten);
  531. x.ArchiveName = archiveName;
  532. x.CurrentEntry = entry;
  533. x.BytesTransferred = bytesWritten;
  534. x.TotalBytesToTransfer = totalBytes;
  535. return x;
  536. }
  537. /// <summary>
  538. /// Number of entries extracted so far. This is set only if the
  539. /// EventType is Extracting_BeforeExtractEntry or Extracting_AfterExtractEntry, and
  540. /// the Extract() is occurring witin the scope of a call to ExtractAll().
  541. /// </summary>
  542. public int EntriesExtracted
  543. {
  544. get { return _entriesExtracted; }
  545. }
  546. /// <summary>
  547. /// Returns the extraction target location, a filesystem path.
  548. /// </summary>
  549. public String ExtractLocation
  550. {
  551. get { return _target; }
  552. }
  553. }
  554. /// <summary>
  555. /// Provides information about the an error that occurred while zipping.
  556. /// </summary>
  557. public class ZipErrorEventArgs : ZipProgressEventArgs
  558. {
  559. private Exception _exc;
  560. private ZipErrorEventArgs() { }
  561. internal static ZipErrorEventArgs Saving(string archiveName, ZipEntry entry, Exception exception)
  562. {
  563. var x = new ZipErrorEventArgs
  564. {
  565. EventType = ZipProgressEventType.Error_Saving,
  566. ArchiveName = archiveName,
  567. CurrentEntry = entry,
  568. _exc = exception
  569. };
  570. return x;
  571. }
  572. /// <summary>
  573. /// Returns the exception that occurred, if any.
  574. /// </summary>
  575. public Exception @Exception
  576. {
  577. get { return _exc; }
  578. }
  579. /// <summary>
  580. /// Returns the name of the file that caused the exception, if any.
  581. /// </summary>
  582. public String FileName
  583. {
  584. get { return CurrentEntry.LocalFileName; }
  585. }
  586. }
  587. }