C# - Get file path from connection string
问题 Is there an existing method in C# to extract the file path from a string that represents a ConnectionString to a SqlCE .sdf file? I want to check if the file exists at initialization and back it up if the file has been modified. Sample connection string: strConn = "Data Source=|DataDirectory|\dbAlias.sdf"; 回答1: A bit late perhaps, but I came across this question wile struggling with the same problem. You can find the location of the |DataDirectory| folder with AppDomain.CurrentDomain.GetData(