[
  {
    "Id": "576930",
    "ThreadId": "248795",
    "Html": "\r\n<p>i'm getting this kind of error. but after i inserted the &quot;goto here:&quot; the program can still &quot;read&quot; the files inside the zipfile.</p>\r\n<p>here is my code..</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><div style=\"color:black; background-color:white\"><pre><span style=\"color:blue\">Imports</span> Ionic.Zip\r\n<span style=\"color:blue\">Imports</span> System.Text.RegularExpressions\r\n<span style=\"color:blue\">Imports</span> System.io\r\n\r\n<span style=\"color:blue\">Dim</span> ZIP <span style=\"color:blue\">As</span> Ionic.Zip.ZipFile\r\n<span style=\"color:blue\">Dim</span> teststr <span style=\"color:blue\">As</span> <span style=\"color:blue\">String</span> = <span style=\"color:#a31515\">&quot;C:\\Input&quot;</span>\r\n\r\n<span style=\"color:blue\">Sub</span> Main()\r\n        <span style=\"color:green\">' Create a new FileSystemWatcher and set its properties.</span>\r\n        <span style=\"color:blue\">Dim</span> watcher <span style=\"color:blue\">As</span> <span style=\"color:blue\">New</span> FileSystemWatcher()\r\n        watcher.Path = teststr\r\n        \r\n        <span style=\"color:green\">' Watch for changes in LastAccess and LastWrite times, and</span>\r\n        <span style=\"color:green\">' the renaming of files or directories. </span>\r\n        watcher.NotifyFilter = (NotifyFilters.LastAccess <span style=\"color:blue\">Or</span> NotifyFilters.LastWrite <span style=\"color:blue\">Or</span> NotifyFilters.FileName <span style=\"color:blue\">Or</span> NotifyFilters.DirectoryName)\r\n        \r\n       <span style=\"color:green\">' Only watch zip files.</span>\r\n        watcher.Filter = <span style=\"color:#a31515\">&quot;*.zip&quot;</span>\r\n\r\n        <span style=\"color:green\">' Add event handlers.</span>\r\n        <span style=\"color:blue\">AddHandler</span> watcher.Created, <span style=\"color:blue\">AddressOf</span> OnChanged\r\n        \r\n\r\n        <span style=\"color:green\">' Begin watching.</span>\r\n        watcher.EnableRaisingEvents = <span style=\"color:blue\">True</span>\r\n\r\n        Console.WriteLine(<span style=\"color:#a31515\">&quot;Exit? Press Enter...&quot;</span>)\r\n        Console.ReadLine()\r\n\r\n        Process.Start(System.AppDomain.CurrentDomain.BaseDirectory &#43; <span style=\"color:#a31515\">&quot;SCST1700Edit.exe&quot;</span>)\r\n\r\n<span style=\"color:blue\">End</span> <span style=\"color:blue\">Sub</span>\r\n\r\n\r\n\r\n<span style=\"color:blue\">Private</span> <span style=\"color:blue\">Sub</span> OnChanged(<span style=\"color:blue\">ByVal</span> source <span style=\"color:blue\">As</span> <span style=\"color:blue\">Object</span>, <span style=\"color:blue\">ByVal</span> e <span style=\"color:blue\">As</span> FileSystemEventArgs)\r\n        <span style=\"color:green\">' Specify what is done when a file is changed, created, or deleted.</span>\r\n        <span style=\"color:blue\">If</span> e.ChangeType = IO.WatcherChangeTypes.Created <span style=\"color:blue\">Then</span>\r\n\r\n\r\n            <span style=\"color:green\">'MsgBox(&quot;File &quot; &amp; e.FullPath &amp; &quot; has been created&quot;)</span>\r\n            <span style=\"color:blue\">Dim</span> strZipfile <span style=\"color:blue\">As</span> <span style=\"color:blue\">String</span>\r\n            <span style=\"color:blue\">Dim</span> arrFileList <span style=\"color:blue\">As</span> <span style=\"color:blue\">New</span> ArrayList()\r\n            <span style=\"color:blue\">Try</span>\r\nhere:\r\n                <span style=\"color:blue\">Using</span> ZIP <span style=\"color:blue\">As</span> <span style=\"color:blue\">New</span> ZipFile(e.FullPath)\r\n                    <span style=\"color:blue\">Dim</span> zipFile <span style=\"color:blue\">As</span> ZipEntry\r\n                    arrFileList.Clear()\r\n                    <span style=\"color:green\">'adds zipfiles in an arraylist</span>\r\n                    <span style=\"color:green\">'and checks if zip contains only tif and idx files</span>\r\n                    <span style=\"color:blue\">For</span> <span style=\"color:blue\">Each</span> zipFile <span style=\"color:blue\">In</span> ZIP\r\n                        strZipfile = zipFile.ToString.Replace(<span style=\"color:#a31515\">&quot;ZipEntry::&quot;</span>, <span style=\"color:#a31515\">&quot;&quot;</span>)\r\n                        <span style=\"color:blue\">If</span> Regex.IsMatch(zipFile.ToString, <span style=\"color:#a31515\">&quot;\\d*(\\.tif|.idx)&quot;</span>) <span style=\"color:blue\">Then</span>\r\n                            arrFileList.Add(strZipfile)\r\n                        <span style=\"color:blue\">Else</span>\r\n                            ErrorPrinter(1, strZipfile)\r\n                        <span style=\"color:blue\">End</span> <span style=\"color:blue\">If</span>\r\n                    <span style=\"color:blue\">Next</span>\r\n                <span style=\"color:blue\">End</span> <span style=\"color:blue\">Using</span>\r\n                StreamReader(arrFileList)\r\n            <span style=\"color:blue\">Catch</span> ex <span style=\"color:blue\">As</span> Exception\r\n                <span style=\"color:blue\">GoTo</span> here\r\n            <span style=\"color:blue\">End</span> <span style=\"color:blue\">Try</span>\r\n\r\n        <span style=\"color:blue\">End</span> <span style=\"color:blue\">If</span>\r\n    <span style=\"color:blue\">End</span> <span style=\"color:blue\">Sub</span>\r\n</pre>\r\n</div>\r\n</pre>\r\n</div>\r\n<p></p>\r\n",
    "PostedDate": "2011-03-07T17:29:47.813-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "576935",
    "ThreadId": "248795",
    "Html": "<p>here's the screenshot of the error: (try catch and goto statement's commented out)</p>\n<p><a href=\"http://s36.photobucket.com/albums/e16/udt670/?action=view&amp;current=zipError.jpg\" target=\"_blank\"><img src=\"http://i36.photobucket.com/albums/e16/udt670/zipError.jpg\" border=\"0\" alt=\"Photobucket\" /></a></p>",
    "PostedDate": "2011-03-07T17:38:44.29-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "577827",
    "ThreadId": "248795",
    "Html": "<div style=\"width: 800px;\">\r\n<p>I think what you have there is a filesystem watcher, which notifies you when the filesystem changes.</p>\r\n<p>Then, your OnChanged event tries reading the file that has changed.</p>\r\n<p>I don't know what is changing the zip file, but... it is possible that a file called Input4.zip is being changed, and while it is being changed, your watcher fires.&nbsp; During the change, the Input4.zip file is not a consistent zip file. Trying to read it, just at that moment, will cause an error.</p>\r\n<p>If I am correct, then the solution is to try to read the zip file only when the changes are complete.&nbsp; I suppose you could also just ignore errors reading the zip file; that would probably be easiest.</p>\r\n<p>&nbsp;</p>\r\n</div>",
    "PostedDate": "2011-03-09T08:18:29.137-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "578315",
    "ThreadId": "248795",
    "Html": "<p>actually i used filesystem watcher to make a \"hot folder\" (that's what we call it ;) )</p>\r\n<p>the system checks if there is a new file created/inserted or paste on the the folder then calls the OnChanged event.</p>\r\n<p>the&nbsp;OnChanged event adds the zipfile to an arraylist. &nbsp;</p>",
    "PostedDate": "2011-03-10T02:49:39.323-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "578371",
    "ThreadId": "248795",
    "Html": "<p>Well I think the possibility I described still exists. I don't have much experience with the FileSystemWatcher. Is it possible that you are getting a Changed event before the zip file is whole?</p>\r\n<p>Your \"goto here\" is a crude approach - you might want to limit the number of retries on the same event, to say... 3.&nbsp; Also you might want to introduce an artificial&nbsp;delay in the event handler, either before first attempting to read the zip file, or after first failure. Finally, you may be able to avoid the retry completely, if it really is true that the FileSystemWatcher fires more than once for a \"Paste\" event in that folder.</p>\r\n<p>It will probably take some experimentation. But, because you yourself have observed that the ZipFile.Read() works fine, the second time through, I think you can conclude that the problem is not in the Ionic.Zip library.&nbsp; It sure seems like a race condition exposed by your code.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-03-10T04:56:15.107-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "578784",
    "ThreadId": "248795",
    "Html": "<p>i don't know if it sense if the copying is complete or not...</p>\r\n<p>i will try that artificial timer...&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>anyways thanks to you and to&nbsp;everyone who made&nbsp;Ionic.Zip. it's a BIG help :)</p>\r\n<p>&nbsp;</p>\r\n<p>ciao!&nbsp;</p>",
    "PostedDate": "2011-03-10T16:19:34.813-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "578982",
    "ThreadId": "248795",
    "Html": "<p>You're welcome, and good luck.</p>\r\n<p>ps: Ionic.Zip was made by one person: Cheeso.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-03-11T04:55:33.703-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]