Catrobat.IDE.Core.Services.Common.ZipService.ZipCatrobatPackage C# (CSharp) Method

ZipCatrobatPackage() public method

public ZipCatrobatPackage ( Stream zipStream, string localStoragePath ) : System.Threading.Tasks.Task
zipStream Stream
localStoragePath string
return System.Threading.Tasks.Task
        public async Task ZipCatrobatPackage(Stream zipStream, string localStoragePath)
        {
            using (var storage = StorageSystem.GetStorage())
            {
                using(var archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
                {
                    await WriteFilesRecursiveToZip(archive, storage, localStoragePath, "");
                    await zipStream.FlushAsync();
                }
            }
            //ZipFile.CreateFromDirectory(localStoragePath, zipPath, CompressionLevel.Fastest, true);
        }

Usage Example

        public async Task LaunchPlayer(Core.Models.Program program, bool isLaunchedFromTile)
        {
            await ShowSplashScreen(program.Name);
            
            var zipService = new ZipService();
            var tempFolder = ApplicationData.Current.TemporaryFolder;
            var file = await tempFolder.CreateFileAsync(TempProgramName, 
                                                        CreationCollisionOption.ReplaceExisting);
            var stream = await file.OpenStreamForWriteAsync();

            await zipService.ZipCatrobatPackage(stream, program.BasePath);

            var options = new Windows.System.LauncherOptions { DisplayApplicationPicker = false };

            //await project.Save(); ??? TODO: this was in the previous version of catrobat --> do we need to save the project at this point?
            await LaunchPlayer(program.Name, isLaunchedFromTile);
            // TODO: manage closing/relaunching of the Player 
            // TODO: review ...LaunchFileAsync (1 line underneath) --> seems to be that it never finishes
            //bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            //if (success)
            //{
            //    // File launch success
            //}
            //else
            //{
            //    // File launch failed
            //}
        }
All Usage Examples Of Catrobat.IDE.Core.Services.Common.ZipService::ZipCatrobatPackage