I was just reading a post by Steve Lasker in which he describes how you can create a SQL Server Compact Edition database and how you can detect if the database already exists. One of my complaints about the introduced “|DataDirectory|” substitution is that it isn’t understood by System.IO. Luckily it doesn’t need to as the .Database property on the SqlCEConnection object returns the path to the database with the appropriate substitution made:
My.Settings.LocalConnectionString:= Data Source =”|DataDirectory|Another.sdf”; Password =”SomePassword”;
Dim localConnection As New SqlCeConnection(My.Settings.LocalConnectionString)
If Not System.IO.File.Exists(localConnection.Database) …