This repository has been archived by the owner on Oct 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d76ff03
commit 2a82df4
Showing
5 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Compression; | ||
|
||
namespace CanvasAppPackager | ||
{ | ||
public class MsAppHelper | ||
{ | ||
public static void CreateFromDirectory(string sourcePath, string outputName) | ||
{ | ||
var files = new List<string>(Directory.GetFiles(sourcePath, "", SearchOption.AllDirectories)); | ||
|
||
using (var zipToOpen = new FileStream(outputName, FileMode.Create)) | ||
using (var archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create)) | ||
{ | ||
foreach (var file in files) | ||
{ | ||
var name = Path.GetRelativePath(sourcePath, file); | ||
ZipFileExtensions.CreateEntryFromFile(archive, file, name); | ||
} | ||
} | ||
} | ||
|
||
public static void AddFiles(Dictionary<string, List<string>> filesByRootPath, string outputName) | ||
{ | ||
using (var zipToOpen = new FileStream(outputName, FileMode.Create)) | ||
using (var archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create)) | ||
{ | ||
foreach (var files in filesByRootPath) | ||
{ | ||
foreach (var file in files.Value) | ||
{ | ||
var name = Path.GetRelativePath(files.Key, file); | ||
ZipFileExtensions.CreateEntryFromFile(archive, file, name); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters