@@ -20,15 +20,29 @@ It does not work with simple compressed streams of data.
20
20
You can create a new ZIP archive like this:
21
21
22
22
``` csharp
23
- var zipArchive =
23
+ var file =
24
24
new ZipExtracted (
25
25
new Zipped (
26
26
" small.dat" , new InputOf (" I feel so compressed" )
27
27
),
28
28
" small.dat"
29
29
).Stream ();
30
30
```
31
-
31
+ or with multiple files
32
+ ``` csharp
33
+ new Zipped (
34
+ new Dictionary <string , IInput >()
35
+ {
36
+ {" small.dat" , new InputOf (" I feel so compressed" ) },
37
+ {" smaller.dat" , new InputOf (" I'm so compressed" ) }
38
+ }
39
+ );
40
+
41
+ new Zipped (
42
+ new KeyValuePair <string , IInput >(" small.dat" , new InputOf (" I feel so compressed" )),
43
+ new KeyValuePair <string , IInput >(" smaller.dat" , new InputOf (" I'm so compressed" ))
44
+ );
45
+ ```
32
46
Update a file in the ZIP:
33
47
34
48
``` csharp
@@ -38,6 +52,15 @@ var updated =
38
52
" Brave Citizens.txt" , new InputOf (" Edward Snowden" )
39
53
).Stream ();
40
54
55
+ ```
56
+ or add a file to the ZIP if it doesn't exist
57
+ ``` csharp
58
+ var updated =
59
+ new ZipUpdated (
60
+ new Zipped (" Brave Citizens.txt" , new InputOf (" Edward Snowden" )),
61
+ " Concerned Citizens.txt" , new InputOf (" Donald" )
62
+ ).Stream ();
63
+
41
64
```
42
65
43
66
Extract a file in the zip:
@@ -51,7 +74,7 @@ var extracted =
51
74
).Stream ();
52
75
```
53
76
54
- List the contents of an archive:
77
+ List the contents (directories and files) of an archive:
55
78
56
79
``` csharp
57
80
IEnumerable < string > contents =
@@ -60,6 +83,15 @@ IEnumerable<string> contents =
60
83
);
61
84
```
62
85
86
+ List all files only of an archive:
87
+
88
+ ``` csharp
89
+ IEnumerable < string > files =
90
+ new ZipFiles (
91
+ new InputOf (File .OpenRead (" c:/some-zip-archive.zip" )),
92
+ );
93
+ ```
94
+
63
95
Remove a file from the archive:
64
96
65
97
``` csharp
@@ -89,6 +121,16 @@ var isZip =
89
121
).Value ();
90
122
```
91
123
124
+ Test if a file exists in a zip:
125
+
126
+ ``` csharp
127
+ var exists =
128
+ new ZipContains (
129
+ new InputOf (File .OpenRead (" c:/some-zip-archive.zip" )),
130
+ " someFileInTheZip.txt" )
131
+ ).Value ();
132
+ ```
133
+
92
134
Test if a file in a zip is protected with a password:
93
135
94
136
``` csharp
0 commit comments