# WorksessionFile class

Namespace: [Rhino.FileIO](https://developer.rhino3d.com/api/rhinocommon/namespace/rhino.fileio.md) · Assembly: [RhinoCommon](https://developer.rhino3d.com/api/rhinocommon/assembly/rhinocommon.md) · Since v9.0

```cs
public sealed class WorksessionFile : IDisposable
```

Reads and writes Rhino worksession (.rws) files. A worksession file lists models and a worksession's layer overrides. It does not contain any model content, and nothing here opens or checks the model files it lists.

**Remarks:** Rhino 4 wrote version 4 files. Rhino 5 and later write version 5. Both versions can be read and written. Models are exchanged by value: [WorksessionFile.GetModel(int)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/getmodel.md) returns a copy, and changes to it are kept only after [WorksessionFile.SetModel(int, WorksessionFileModel)](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/setmodel.md).

## Constructors

- [WorksessionFile](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/ctor.md): (2 overloads) Creates an empty worksession with no models.

## Finalizer

- [~WorksessionFile](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/finalize.md): Releases the native worksession.

## Properties

- [ActiveModelIndex](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/activemodelindex.md): Gets the index of the first active model, or -1 if there is no active model.
- [CurrentVersion](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/currentversion.md): (static) The worksession file version Rhino 5 and later write.
- [ModelCount](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/modelcount.md): Gets the number of models.
- [Version](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/version.md): Gets or sets the file version. Reading sets it to the version of the file that was read. Writing does not use it.

## Methods

- [AddModel](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/addmodel.md): Adds a copy of a model to the end of the list.
- [ClearModels](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/clearmodels.md): Removes all of the models.
- [Dispose](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/dispose.md): Releases the native worksession.
- [Dump](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/dump.md): Describes the worksession: its version, and for each model its paths and saved layer settings. For each saved layer it gives its name and the settings Rhino uses.
- [FromByteArray](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/frombytearray.md): (static) Reads a worksession from the contents of a worksession file.
- [GetModel](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/getmodel.md): Gets a copy of a model.
- [GetModels](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/getmodels.md): Gets copies of all of the models.
- [Read](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/read.md): (static) Reads a worksession file.
- [ReadFileVersion](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/readfileversion.md): (static) Reads only the version from the header of a worksession file.
- [RemoveModelAt](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/removemodelat.md): Removes a model.
- [SetModel](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/setmodel.md): Replaces a model with a copy of another.
- [ToByteArray](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/tobytearray.md): (2 overloads) Writes the worksession as the contents of a version 5 .rws file.
- [Write](https://developer.rhino3d.com/api/rhinocommon/type/rhino.fileio.worksessionfile/write.md): (2 overloads) Writes a worksession file.
