This repository has been archived by the owner on Aug 18, 2023. It is now read-only.
/
Program.cs
46 lines (43 loc) · 1.83 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Compression;
using System.IO;
namespace Zippy
{
class Program
{
static void Main(string[] args)
{
string zipPath = @"C:\\Users\\rainaldo crosbourne\\Documents\\GitHub\\Zippy\\zippy_files\\test.zip";
string outputFile = @"C:\\Users\\rainaldo crosbourne\\Documents\\GitHub\\Zippy\\zippy_files\\t2.txt";
//Create the zip archive
//ZipFile.CreateFromDirectory(Path.GetDirectoryName(zipPath), zipPath);
//Add entries to the archive
//Close the archive
//using (ZipArchive archive = ZipFile.OpenRead(zipPath))
//{
//}
//Creates a new, blank zip file to work with - the file will be
//finalized when the using statement completes
using (ZipArchive newFile = ZipFile.Open(zipPath, ZipArchiveMode.Create))
{
ZipArchiveEntry readmeEntry = newFile.CreateEntry(Path.GetFileName(outputFile),CompressionLevel.Fastest);
using (StreamWriter writer = new StreamWriter(readmeEntry.Open()))
{
writer.WriteAsync("This is a test file writen and stream and added to zip file");
}
//using (System.IO.StreamWriter outFile = new System.IO.StreamWriter(outputFile))
//{
//Output file name
// outFile.Write(string.Format("The test file\n"));
// //Iterate through Report dictionary
// }
//newFile.CreateEntryFromFile(outputFile, Path.GetFileName(outputFile), CompressionLevel.Fastest);
}
Console.ReadKey();
}
}
}