Coolbits Tips

.NET and general software development tips and articles I've written.

Go Back

An Excellent Character- "~"

The other day I was working on on the web setup project for Mister Lister. I was having a problem with some of the application settings in the web.config. These settings indicate path information for files necessary for Peter's Date Package and Professional Validation and More. The files are installed with Mister Lister in sub-folders of the main application. In the web.config, I was referencing the folders like this:


  <add key="PDP_ScriptVirtualPath" value="/Lister/DatePicker/Scripts/" />

Of course, that's great until the user installs Mister List in a virtual directory other than "Lister". I spent most of today thinking about adding a custom action to my setup that would change the entries in the web.config (ick!)


It just dawned on me that instead, I can use the tilde (~) character. This represents the application virtual directory. Now, my entries look like this:


  <add key="PDP_ScriptVirtualPath" value="~/DatePicker/Scripts/" />

It doesn't matter which virtual directory they are installed in, the web.config is fine. Or, I can even install Mister Lister in the application root. Yippy! Problem solved.