Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Error "EOF in Header" Sharpzip Lib with Unity

$
0
0

I'm trying to implement a unity App for android where my app extract a Zip file that it previously downloaded to a folder, i've been looking around and the SharpZip lib was one of the most recommended option. After importing the library to my project i tried this bit of code but it keep giving me an EOF in Header error and i can't see from where it come, i am using 7zip to compress the file and inside i have a fbx model, an image and a folder with multiple images, if someone could help me or at least give me some idea of what i have to look for. 

Code: 

string docPath = Application.dataPath;

docPath = docPath.Substring(0, docPath.Length - 5);

docPath = docPath.Substring(0, docPath.LastIndexOf("/"));

docPath += "/Documents/test.zip";

Debug.Log("docPath=" + docPath);

using (ZipInputStream s = new ZipInputStream(File.OpenRead(docPath)))

{

ZipEntry theEntry;

while ((theEntry = s.GetNextEntry()) != null)

{

Console.WriteLine(theEntry.Name);

string directoryName = Path.GetDirectoryName(theEntry.Name);

string fileName      = Path.GetFileName(theEntry.Name);

// create directory

if ( directoryName.Length > 0 )

{

Directory.CreateDirectory(directoryName);

}

if (fileName != String.Empty)

{

string filename = docPath.Substring(0, docPath.Length - 8);

filename += theEntry.Name;

Debug.Log("Unzipping: " + filename);

using (FileStream streamWriter = File.Create(filename))

{

int size = 2048;

byte[ fdata = new byte[2048];

while (true)

{

size = s.Read(fdata, 0, fdata.Length);

if (size > 0)

{

streamWriter.Write(fdata, 0, size);

}

else

{

break;

}

}

}

}

}

isUnzipped = true;

 

}


Viewing all articles
Browse latest Browse all 1764

Trending Articles