Bloom.BloomZipFile.AddDirectory C# (CSharp) Method

AddDirectory() public method

Adds a directory, along with all files and subdirectories
public AddDirectory ( string directoryPath ) : void
directoryPath string The directory to add recursively
return void
        public void AddDirectory(string directoryPath)
        {
            var rootName = Path.GetFileName(directoryPath);
            if (rootName == null)
                return;

            var dirNameOffest = directoryPath.Length - rootName.Length;
            AddDirectory(directoryPath, dirNameOffest);
        }

Same methods

BloomZipFile::AddDirectory ( string directoryPath, int dirNameOffest ) : void

Usage Example

        public void UploadSmokeTest()
        {
            using(var folder = new TemporaryFolder("Upload Smoke Test"))
            {
                File.WriteAllText(folder.Combine("hello there.txt"), "hello there");
                using(var bookZip = TempFile.WithFilenameInTempFolder("Upload Smoketest.zip"))
                {
                    var zip = new BloomZipFile(bookZip.Path);
                    zip.AddDirectory(folder.FolderPath);
                    zip.Save();

                    var progress = new StringBuilderProgress();
                    ProblemBookUploader.UploadBook(BloomS3Client.UnitTestBucketName, bookZip.Path,progress);
                    Assert.IsTrue(progress.Text.Contains("Success"), progress.Text);
                }
            }
        }