Figaro - The XML Database for the .NET Framework

To use an environment, you must first open it. At open time, you must identify the directory in which it resides and this directory must exist prior to the open attempt. At open time, you also specify the open flags, properties, if any, that you want to use for your environment.

When you are done with the environment, you must make sure it is closed. You can either do this explicitly, or you can have the XmlManager object do it for you.

If you are explicitly closing your environment, you must make sure an containers opened in the environment have been closed before you close your environment.

For information on XmlManager instantiation, see XmlManager Instantiation and Destruction. For example:

CopyC#
public void OpeningAndClosingEnvironments()
{
    using (FigaroEnv env = new FigaroEnv())
    {
        try
        {
            const EnvOpenOptions flags = EnvOpenOptions.UseEnvironment |
                EnvOpenOptions.Create |
                EnvOpenOptions.InitLock |
                EnvOpenOptions.InitLog;
            env.Open(@"C:\dev\db\", flags);
            env.Close();
        }
        catch (DatabaseException de)
        {
            Log("Example31", "DatabaseException caught. Error code: " + de.ErrorCode + ", message: " + de.Message);
        }
        catch (Figaro.BerkeleyDB.Xml.XmlException de)
        {
            Log("Example31", "XmlException caught. Error code: " + de.ErrorCode + ", message: " + de.Message);
        }
        catch (FigaroException de)
        {
            Log("Example31", "FigaroException caught. Error code: " + de.ErrorCode + ", message: " + de.Message);
        }
    }
}

See Also