I'm trying to use DotNetZip to handle zip files, but whenever I try to open a file I get the following error:
[SEVERE] System.ArgumentException: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password)
at Ionic.Zip.ZipEntry.Extract(String baseDirectory)
at Ionic.Zip.ZipFile._InternalExtractAll(String path, Boolean overrideExtractExistingProperty)
at Ionic.Zip.ZipFile.ExtractAll(String path)
at ModsInstaller.Form1.MergeDirectories(String Path1, String Path2) in C:\Users\Admin\documents\visual studio 2010\Projects\ModsInstaller\ModsInstaller\Form1.cs:line 275
at ModsInstaller.Form1.CustomInstallForge() in C:\Users\Admin\documents\visual studio 2010\Projects\ModsInstaller\ModsInstaller\Form1.cs:line 259
at ModsInstaller.Form1.btn_install_Click(Object sender, EventArgs e) in C:\Users\Admin\documents\visual studio 2010\Projects\ModsInstaller\ModsInstaller\Form1.cs:line 120
and here's the code:
private void MergeDirectories(string Path1, string Path2)
{
string outDirectory = Path.GetFullPath(workspace + "\\temp\\dir");
if (!Directory.Exists(outDirectory))
Directory.CreateDirectory(outDirectory);
Path1 = Path.GetFullPath(Path1);
Path2 = Path.GetFullPath(Path2);
Log("Extracting {0} to temp dir.", Path1);
using (ZipFile zip = ZipFile.Read(Path1))
{
zip.ExtractAll(outDirectory); //this line throws the error
}
Log("Extraction sucessfull");
Log("Extracted {0} to temp dir.", Path2);
ZipFile.Read(Path2).ExtractAll(Path.GetFullPath(workspace + "\\temp\\dir"));
Log("Extraction sucessfull");
ZipFile z = new ZipFile(workspace + "\\temp\\build.jar");
z.AddDirectory(workspace + "\\temp\\dir");
z.Save();
z.Dispose();
}
and when I insert a breakpoint I see that:
outDirectory = "C:\\Users\\Admin\\documents\\visual studio 2010\\Projects\\ModsInstaller\\ModsInstaller\\bin\\Debug\\temp\\dir"
Can anyone point out what I'm doing wrong?
Thanks.