Writing from a Stream to a File

  • Thread starter Thread starter Rasika
  • Start date Start date
R

Rasika

I have zip file called "PPC_DATA.zip" that contains four
jpg images. Using the code below I can get a ZipEntry,
which can be converted into a Stream by using
zFile.GetInputStream(e). I want to know how to write the
Stream I get in this way into files.


I have included the code below, but converting the Stream
(from 'zFile.GetInputStream(e);') into a file named
('e.Name;') is confusign me...

===========

ZipFile zFile = new ZipFile(@"c:\My
Documents\PPC_DATA.zip");

foreach (ZipEntry e in zFile) {
FileStream fs = new FileStream(@"C:\My
Documents\" + e.Name, FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);

//zFile.GetInputStream(e);

}
 
Rasika said:
I have zip file called "PPC_DATA.zip" that contains four
jpg images. Using the code below I can get a ZipEntry,
which can be converted into a Stream by using
zFile.GetInputStream(e). I want to know how to write the
Stream I get in this way into files.


I have included the code below, but converting the Stream
(from 'zFile.GetInputStream(e);') into a file named
('e.Name;') is confusign me...

Have a look at the bottom example in
http://www.yoda.arachsys.com/csharp/readbinary.html

That happens to write to a memory stream instead of a file stream, but
the "read a block, write it" loop is the same as what you need.
 
Back
Top