# LINQPad 如何多機共用 Queries、Snippets 與 Plugins and Extensions 資料夾

[LINQPad](https://www.linqpad.net/) 有三個資料夾，預設放在使用者目錄的「我的文件」目錄下(`~/Documents`)，分別是 `LINQPad Plugins`, `LINQPad Queries`, `LINQPad Snippets` 這三個。為了讓我的筆電與家中電腦可以同步這些資料，我特別將這幾個資料夾移至 [Dropbox](https://www.dropbox.com/referrals/AAClio8-QkP1MXlLIP237JfCUmgj4DdBkrk?src=global9) 共享資料夾中，然後透過 Symbolic Link 連結回去，如此一來我就不用特別調整 LINQPad 設定，我只要調整每台電腦的資料夾與連結設定，就可以很方便的讀取到同步後的 LINQPad 完整設定與資料。

我為了完成這個任務，特別寫了一個 PowerShell 模組，並且上架到 [PowerShell Gallery](https://www.powershellgallery.com/)，只要透過簡單的安裝，就可以立即執行，以下就是使用的方式：

1.  安裝模組
    
    ```powershell
    Install-Module linqpad-folders-powershell-module -Force
    ```
    
    若是要更新版本，可以使用以下命令：
    
    ```powershell
    Update-Module linqpad-folders-powershell-module -Force
    ```
    
2.  將 LINQPad 資料夾移至指定資料夾
    
    這裡的 `-TargetPath` 參數用來指定你希望儲存 LINQPad 設定的目標路徑，你必須先建立好該資料夾，才能執行以下命令：
    
    ```powershell
    Set-LINQPadFolder -TargetPath '~/Dropbox/Tools/LINQPad'
    ```
    
    ![LINQPad Folders](https://stwillblogassets.blob.core.windows.net/files/images/external/user-images.githubusercontent.com/2a02d9646891f3e1aba3-157466207-3bdb855a-085a-48a5-82d9-231ac5762172.png)
    
    > 注意：在 Windows 下的 PowerShell 看的懂 `~` 符號，預設代表使用者家目錄，也就是以前在 Command Prompt 底下的 `%USERPROFILE%` 目錄。
    
    如果你電腦的「我的文件」資料夾不在預設的 `~/Documents` 目錄，可以使用 `-DefaultPath` 參數明確指定路徑在哪裡：
    
    ```powershell
    Set-LINQPadFolder -DefaultPath '~\OneDrive\Documents' -TargetPath '~/Dropbox/Tools/LINQPad'
    ```
    

### 相關連結

-   原始碼: [https://github.com/doggy8088/linqpad-folders-powershell-module](https://github.com/doggy8088/linqpad-folders-powershell-module)
-   [PowerShell Gallery | linqpad-folders-powershell-module 0.1.0.0](https://www.powershellgallery.com/packages/linqpad-folders-powershell-module/0.1.0.0)
-   [PowerShell 資源庫](https://learn.microsoft.com/zh-tw/powershell/scripting/gallery/overview?view=powershell-7.2&WT.mc_id=DT-MVP-4015686) / [The PowerShell Gallery](https://learn.microsoft.com/en-us/powershell/scripting/gallery/overview?view=powershell-7.2&WT.mc_id=DT-MVP-4015686)
-   [LINQPad - The .NET Programmer's Playground](https://www.linqpad.net/)
