Given the following connection string (for SQL Server CE 4.0)
Data Source=|DataDirectory|IntegrationTests.sdf
how do I figure out if the file exists?
(I know I can hard-code the path in a call to File.Exists(), but I don’t want to. What if I decide to change the connection string?)
Perhaps use the
SqlConnectionStringBuilderClass to parse your connection string into its component pieces:In this case you can use the
DataSourceproperty: