How to add multiple query folders in LINQPad?

There's no way to display more than one root folder in 'My Queries' at present. If you like, add a suggestion at linqpad.uservoice.com so we can guage demand.


The answer I am adding here does not resolve the implicit question of, "how does one have multiple root level folders in LINQPad." However, I think it provides a solution to the question of, how "to include more than one folders [sic] in My Queries to organize my codes?"

Technique 1 - Just add folders (arguably worse than Technique 2)

You can have multiple sub folders under the My Queries folder, and they will all show up. This adds the benefit of being able to organize your queries a bit, with the downside being the fact that you will probably include a lot more files and folders than you intend to:

A screenshot of my My Queries that shows too many folders.

To add folders, just navigate to your My Queries folder in File Explorer, and add a new folder. Refreshing your My Queries pane will the display the new folder.

Technique 2 - Symbolic Links

You can achieve a similar result as Technique 1 by using symbolic links. The benefit to this approach is that you can link just the folders that you want (e.g. folders that contain scripts), while leaving everything else alone:

enter image description here

Please note that creating symbolic links typically requires administrative privileges on a computer.

Creating symbolic links is easy with Powershell:

# By not changing the value for "Path," this will create a symbolic link in the current folder
# that is named whatever value is given for "Name," and it will be pointed to whatever value
# "Value" is set to.
new-item -ItemType SymbolicLink -Path . -Name "ExampleSharedScripts" -Value "Path to actual folder"

The difference between the two techniques

To explain what is really different between the two techniques, I'll explain the folder structure from the pictures a bit more:

In technique 1, an entire repository is shown due to the fact that the entire repository is kept under the My Queries folder. In technique 2, my repository is stored somewhere else entirely, but I have added a symbolic link in my My Queries folder that points to the queries contained within the repository itself. Technique 2 allows me to store my repositories in a more appropriate place, while still allowing for the convenience of having scripts show up in the My Queries pane of LINQPad.

Other reading

A couple of blog posts have been put out on the internet with some tips and tricks around LINQPad. This blog post from Dan Clarke talks about how he creates symbolic links to manage his scripts (he also lists some other tricks).

Tags:

Linqpad