Does anyone know how to get hold of the path to the directory where the LINQPad script file (.linq) resides?
Or to the script itself for that matter.
Note that I'm not talking about the location of the "My Queries" folder, the one shown inside LINQPad.
I can save a .linq file anywhere on disk, and open it by double-clicking on it.
For instance, if I save the file to C:\Temp\Test.linq
, and execute the program, I'd like to have either C:\Temp
or C:\Temp\Test.linq
.
Basically I'd like something akin to Environment.CurrentDirectory
or Assembly.GetEntryAssembly().Location
, just for the .linq file.
Things I've tried:
Environment.CommandLine.Dump();
- gives LINQPad executableEnvironment.CurrentDirectory.Dump();
- gives C:\windows\system32Assembly.GetExecutingAssembly().Location.Dump();
- gives temp directoryConnection details are normally stored in %appdata%\LINQPad\ConnectionsV2. xml. However, if you move/copy this file into the folder where LINQPad.exe resides, LINQPad will use that copy instead. (This makes life easy when xcopy-deploying LINQPad for portable or shared deployments.)
A LINQ file is a text file created by LINQPad, a utility that helps . NET Framework developers test code outside of IDEs like Microsoft Visual Studio.
Click on "Add connection"; a window will appear. Choose "Default (LINQ to SQL)" and click on the "Next" button. A new window will appear, fill in the required details to get connected with the desired database.
I've just added a feature to address this. You can test it now by downloading the 2.27.1 or 4.27.1 beta build.
To get the current query's folder, use the following expression:
Path.GetDirectoryName (Util.CurrentQueryPath)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With