Skip to content Skip to sidebar Skip to footer

Programatically Retrieve The Full Data Directory Path In Vb.net

I am working on a VB.NET / WPF application which will use SQL Compact Edition databases. The application should allow the user to save and load different versions of the database.

Solution 1:

You could save all the data in the same folder as the application:

System.AppDomain.CurrentDomain.BaseDirectory

However if you are not sure you have access to that folder you can always write to the Application Data which is made for this:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

Then in this location you can create your own application directory and then your sub directories.

simple example would be:

Dim DataPath asString = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "/MyApplication/Data/"
connectionString="Data source=|" & DataPath &"myDatabase.sdf;"

Post a Comment for "Programatically Retrieve The Full Data Directory Path In Vb.net"