see sharp RSS 2.0
# Thursday, 07 May 2009
If you need to zip a file or files you can use the java zip utilities supplied with VS.
All you have to do is to add vjslib.dll and vjslibcws.dll .net assemblies as project references.
They are present whe you install Visual J#. It can easily handle multiple files.
 
// ZIP Test
string inputFileName = @"C:\test.txt";
string zipFileName = Path.ChangeExtension(inputFileName, "ZIP"
);
string zipEntryName = Path
.GetFileName(inputFileName);
java.io.
FileOutputStream fileStream = new java.io.FileOutputStream
(zipFileName);
java.util.zip.
ZipOutputStream outputStream = new java.util.zip.ZipOutputStream
(fileStream);
java.io.
FileInputStream inputStream = new java.io.FileInputStream
(inputFileName);
java.util.zip.
ZipEntry zipEntry = new java.util.zip.ZipEntry
(
zipEntryName);
outputStream.putNextEntry(zipEntry);
sbyte[] buffer = new sbyte
[2048];
int
bytes = 0;
while
((bytes = inputStream.read(buffer, 0, buffer.Length)) > 0)
{
   outputStream.write(buffer, 0, bytes);
}
outputStream.closeEntry();
inputStream.close();
outputStream.close();

 
This was a nice try, but J# has been removed from VS2008.
To enable your application for ZIPs use dotnetzip: http://dotnetzip.codeplex.com/.
... or you may want to look at the OPC packaging API at http://msdn.microsoft.com/en-us/library/system.io.packaging.package.aspx
Thursday, 07 May 2009 19:29:30 (Mitteleuropäische Sommerzeit, UTC+02:00)  #    -
C# | OPC
Archive
<2017 December>
SunMonTueWedThuFriSat
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
Any link on this site may lead to an external website that is not under my control and that external website might show an opinion that is not mine.

© Copyright 2017
Hannes Köhler
Sign In
Statistics
Total Posts: 39
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2017, Hannes Köhler
DasBlog theme 'Business' created by Christoph De Baene (delarou)