Unhandled Exception using DotNetZip

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maylortaylor
    New Member
    • Nov 2012
    • 72

    Unhandled Exception using DotNetZip

    I've been using DotNetZip for a month or so now and i like how it has worked but today my program started having a new issue that I'm clueless on.

    During the zipping process it throws this error up and windows displays their "*program name* has stopped working" box.
    Code:
        Unhandled Exception: System.IO.FileNotFoundException: s:\(file path)\filename.pdf
        at Ionic.Zip.SharedUtilities.GetFileLength(string fileName)
        at ionic.Zip.ZipEntry.MaybeUnsetCompressionMethodForWriting(int32 cycle)
        at Ionic.zip.Zipentry.WriteHeader(Stream s, Int32 cycle)
        at Ionic.zip.ZipEntry.Write(Stream s)
        at Ionic.zip.zipfile.save()
        at ZipAJob_Instant.ConsoleMain.Main() in C:\users\(my name)\Documents\visual studio 2012\projects\zipAjob_Instant\zipAJob_Win32.vb:line 71
    Line 71 refers to where i call zip.save()

    Code:
    For Each item As System.Xml.XmlNode In Source
                            If item.InnerText.Contains(".") Then
                                zip.AddFile(item.InnerText, "")
                            Else
                                zip.AddDirectory(item.InnerText, GetLastDirName(item.InnerText & " "))
                            End If
                        Next
    Code:
    For Each item As System.Xml.XmlNode In Destin
                            Dim time As DateTime = DateTime.Now
                            Dim format As String = "MMMddyyyy"
                            Dim zpath As String = item.InnerText
                            ''''Replaces [date] in destination with backup date
                            If time.DayOfWeek = 1 Then
                                time = time.AddDays(-1)
                                item.InnerText = Replace(item.InnerText, "[date]", time.ToString(format) & "_WE")
                                zpath = item.InnerText
                                zip.ParallelDeflateThreshold = -1
                                Console.WriteLine("...Zipping " & GetLastDirName(item.InnerText & " "))
                                                            zip.Save(zpath)
                                                        Else
                                Dim time1 As DateTime = DateTime.Now.AddDays(-1)
                                item.InnerText = Replace(item.InnerText, "[date]", time1.ToString(format))
                                zpath = item.InnerText
                                zip.ParallelDeflateThreshold = -1
                                Console.WriteLine("...Zipping " & GetLastDirName(item.InnerText & " "))
                                                            zip.Save(zpath)
                                                        End If
                        Next
    Last edited by maylortaylor; Feb 25 '13, 07:54 PM. Reason: Added more code
  • Mikkeee
    New Member
    • Feb 2013
    • 94

    #2
    Great detailed error message but you neglected to post the code that's generating the error.

    Comment

    Working...