|DataDirectory| - This is the designation of the connection string and is not related to the file system.
You can delete the file using the following code:
var directoryName = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var fileName = Path.Combine(directoryName, "Foo2Database.sdf");
File.Delete(fileName);
You can get the current DataDirectoryone through AppDomain.CurrentDomain.GetData("DataDirectory");if you install it.
If you have asp.net DataDirectory, the default will be Server.MapPath("~/App_Data");.
source
share