Question:
I am trying to get at some data in an Autodesk Revit file, which is just a ZIP under the skin. I can use 7zip to extract but I am hoping to automate things with all native PS or Windows. I tried Expand-Archive after I renamed the RVT file to ZIP, but Expand-Archive has an odd error. The code is
1 2 |
Expand-Archive -path:'C:\RevitVersionTest\22-PLUMB-CLR-RECTANGULAR.zip' -destinationPath:'C:\Revit Fam' |
And the error is
New-Object : Exception calling “.ctor” with “3” argument(s): “End of Central Directory record could not be found.”
Answer:
The file is corrupt. Re-download (or obtain) the ZIP file.
Background: I landed here having experienced the same error downloading a ZIP from Google Drive through a private link:
1 2 |
Invoke-WebRequest -Uri $zipFile -OutFile "$destPath\myZip.zip" |
…then using the command:
1 2 |
Expand-Archive c:\a.zip -DestinationPath c:\a` |
The file downloaded but it wouldn’t extract. I downloaded through the browser using the UI, and then compared the download file sizes. Sure enough, the downloaded ZIP was corrupted. When I updated the URL to a Google Docs link directly to the file (that’s public with permission), the ZIP then downloaded and extracted correctly.
Hence, comments under the question alluding to the file being corrupt are correct.