0

I had a piece of code that working without issue on Windows XP . Not our company has migrated to windows 7 and the software stopped working. De code itself opens an zip-file and extracts the content. Following it reads the content.

    Dim tempzip As String = "C:\ some very long path\bin\Debug\lib.zip"
    Dim tempdir As String = IO.Path.Combine(IO.Path.GetTempPath, Guid.NewGuid.ToString)
    Using zip1 As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(tempzip)
        Dim e As Ionic.Zip.ZipEntry
        For Each e In zip1
            e.Extract(tempdir, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently)
        Next
    End Using
    PropertiesAssembly = System.Reflection.Assembly.LoadFrom(IO.Path.Combine(tempdir, "some dll in zip-file"))

The error occurs at the e.Extract . He could apparently not find the zip-file. The exception thrown is your standard Could not find file or part of file...

The Zip-file does exist at the specified location and the needed assembly is present in the zip-file. The code has not been altered yet. This was merely a test to check the working.

Question: Is there a difference between windows 7 & windows xp in file-handling? if not, what might the cause of this strange behavior

User999999
  • 2,500
  • 7
  • 37
  • 63

1 Answers1

1

I think its most likely the GetTempPath function returning different paths (the Temp folder does change). On XP, the path was short enough that adding the length of the Guid and the folders names in the zip file stayed within the limit of the max path name (I think 256 characters?), while on W7 GetTempPath returned a longer name which pushed the resulting paths over the limit.

This assuming that the zip file actually does exist where the program thinks it is.

Wooble
  • 87,717
  • 12
  • 108
  • 131
simon at rcl
  • 7,326
  • 1
  • 17
  • 24
  • Checked the zipfile. It is present at the definied location. You might be right about the pathlength. I will to use a fix (and short) path this afternoon. – User999999 Jan 31 '14 at 12:55
  • Jackpot! indeed the length was indeed too long. The max length allowed is 260 chars. On Xp it was around the 240 chars on Win7 it exceeded 280 chars... Cheers mate – User999999 Jan 31 '14 at 13:29