You are misunderstanding how it works.
Setting the DataDirectory is correct, but the actual connectionstring is not changed on file.
When you open the connection the |DataDirectory|
part of the string will be replaced with your path
You just need to try and see by yourself