Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Extract Zip File

$
0
0

I have a zip file, which contains several txt files, I'm trying to extract the text files, but I can not because when I extract the file is on the device as if it were corrupted.,

in project DROID

public async Task Extrair(string path, string destino){
using ( ZipInputStream s = new ZipInputStream ( File.OpenRead (path ) ))
{
ZipEntry theEntry;
while ( ( theEntry = s.NextEntry ) != null )
{
string directoryName = Path.GetDirectoryName ( theEntry.Name );
string fileName = Path.GetFileName ( theEntry.Name );
directoryName = Path.Combine ( destino , directoryName );
if ( directoryName.Length > 0 )
{
Directory.CreateDirectory ( directoryName );
}
if ( fileName != String.Empty )
{
using ( FileStream streamWriter = File.Create ( Path.Combine ( destino , theEntry.Name ) ) )
{
int size = theEntry.Size;
byte [] data = new byte[size];
while ( true )
{
size = s.Read ( data , 0 , data.Length );
if ( size > 0 )
{
streamWriter.Write ( data , 0 , size );
}
else
{
break;
}
}
}
}
}
}
}


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>