How do I check if a database exist in esent?
I can use Api.JetAttachDatabase
and Api.JetOpenDatabase
to open an existing database and use Api.JetCreateDatabase
to create a new one. But I can't find an API that allows me to check whether a DB exists.
Do I really have to catch an exception from Api.JetAttachDatabase
to detect if the db exist?
I'll apologize for the lack of details because I'm on vacation and don't have the source code handy. :) This is off the top of my head.
o Api.JetAttachDatabase calls JetApi.JetAttachDatabase.
o JetApi.JetAttachDatabase returns an error code (which is what you want!).
o Api.JetAttachDatabase converts that to an exception.
The biggest problem may be that JetApi.Xxx may not be public. It may be internal-only. I'd have to ask the original author if there's a reason for it not be public. If there isn't one, I can make the change in a future release of ManagedEsent.
Sorry for the uncertain answer.
Hey, I was just wondering: what about a CLR function, like File.Exists() ?
-martin