## CreateEntries(DirectoryInfo, bool) {#createentries}

Add to the archive all files and directories recursively in the directory given.

```csharp
public Archive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)
```

| Parameter | Type | Description |
| --- | --- | --- |
| directory | DirectoryInfo | Directory to compress. |
| includeRootDirectory | Boolean | Indicates whether to include the root directory itself or not. |

### Return Value

The archive with entries composed.

### Exceptions

| exception | condition |
| --- | --- |
| DirectoryNotFoundException | The path to *directory* is invalid, such as being on an unmapped drive. |
| SecurityException | The caller does not have the required permission to access *directory*. |
| ObjectDisposedException | Thrown if the archive has been disposed. |
| ArgumentNullException | *directory* is `null`. |

## Examples

```csharp
using (Archive archive = new Archive())
{
    DirectoryInfo folder = new DirectoryInfo("C:\folder");
    archive.CreateEntries(folder);
    archive.Save("folder.zip");
}
```

### See Also

* class [Archive](../)
* namespace [Aspose.Zip](../../archive/)
* assembly [Aspose.Zip](../../../)

---

## CreateEntries(string, bool) {#createentries_1}

Add to the archive all files and directories recursively in the directory given.

```csharp
public Archive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)
```

| Parameter | Type | Description |
| --- | --- | --- |
| sourceDirectory | String | Directory to compress. |
| includeRootDirectory | Boolean | Indicates whether to include the root directory itself or not. |

### Return Value

The archive with entries composed.

### Exceptions

| exception | condition |
| --- | --- |
| ObjectDisposedException | Thrown if the archive has been disposed. |
| ArgumentException | *sourceDirectory* contains invalid characters such as ", &lt;, &gt;, or &#x7C;. |
| ArgumentNullException | *sourceDirectory* is `null`. |
| PathTooLongException | The specified path, file name, or both exceed the system-defined maximum length. |

## Examples

```csharp
using (Archive archive = new Archive())
{
    archive.CreateEntries("C:\folder");
    archive.Save("folder.zip");
}
```

### See Also

* class [Archive](../)
* namespace [Aspose.Zip](../../archive/)
* assembly [Aspose.Zip](../../../)


