views:

551

answers:

1

Hi I am beginner. I load data from sdf database in winforms App. I use full path to the database file . Example :

conn = new SqlCeConnection

{

ConnectionString ="Data Source=F:\\My Documents\\Project1\\bin\\Debug\\Database.sdf"

};

I d like use a relative path to the database file. For example. I have sdf file in folder F:\My Documents\Project1\bin\Debug\Data\file.sdf and I want use relative path in connection string. Any advice ? Thank you.

+1  A: 

Relative to what your application ? If so then you can simply get the applications current Path with :

System.Environment.CurrentDirectory

And append it to the connection string

RC1140