none
How do I type a relative path for the Documents folder for any computer? RRS feed

  • Question

  • I recently setup a git repository to sync my code between my pc and my laptop and I successfully pulled up the code on my laptop but the includes are all wrong because the libraries I included were stored in the Documents folder. This is a problem because my PC uses B:/Documents and my laptop uses something like C:/Users/.../Onedrive/Documents. How do I tell Visual Studio to find the current computers Documents folder no matter what location is defined for that specific computer.
    Sunday, October 6, 2019 7:08 PM

All replies

  • The old way was to add folder to source control with the dlls you were referencing and reference them from the folder in source control.   The newer and better solution is to put the dlls you are referencing from a NuGet feed. If you are using azure dev ops you can host nuget packages there, you can use a 3rd party like MyGet, or host the feed your self.

    https://docs.microsoft.com/en-us/nuget/hosting-packages/nuget-server

    https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds

    Sunday, October 6, 2019 7:23 PM
  • In some circumstances you can use the following special folder name:

       "%USERPROFILE%\Documents"

    Monday, October 7, 2019 5:11 AM
  • Hi lnvilis,

    Welcome to the MSDN forum.

    If your PC recognizes b disk as the system disk by default, you'd better use the system variable, which allows the system to select the location of the respective documents in different computer environments without error.

    >>>use the path"%USERPROFILE%\Documents"

    This allows you to identify and select individual document addresses in different system environments.

    Any feedback will be expected.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Monday, October 7, 2019 7:08 AM
  • Hi Invilis,

    Sorry for bothering you, just confirm if your problem has been solved.

    If this issue still persists, we recommend you could open csproj file as notepad, then change hintpath of reference like below:

    <Reference Include="ClassLibrary1">
          <HintPath>..\..\..\..\Documents\ClassLibrary1.dll</HintPath> //on my side, the relative path means "C:\users\[unsername]\Documents\xx.dll"
    </Reference>

    And also, you could change "Copy Local" which is a property of assembly to "True", it will be automatically copied to output path and the project would automatically reference it when it is not in specified directory.

    Hope it could help you,and look forward to your feedback.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Thursday, October 10, 2019 6:00 AM
  • My documents folder is on B:\ and stuff like this, %USERPROFILE%\Documents, don't work, probably because I set the location to the B drive myself and the C drive is the OS drive so these shortcuts must not recognize my changes. How should I proceed, is that hint path thing the right way to go?
    Saturday, December 14, 2019 2:54 AM