0

I have an application that I need to give a certain path of a file or the path of the folder that contains the file and it will retrieve the file automatically.

The thing is the application will run on different PCs and therefore the path will have some changes. for example

I have a path let's say like this C:\Users\main user\Templates\Test Assembly\Test.txt

\Templates\Test Assembly\Test.txt this part of the path will not be changed.

the part that will be changed is C:\Users\main user depending on the placement of the main folder on each PC as the folder will be on the SharePoint.

is there a way I can retrieve the full path while only providing the second part of it \Templates\Test Assembly\Test.txt

I am using vb.net as my language but feel free to chip in with the idea and I can change the syntax later.

I don't want to put the folder in the same path as the solution folder.

HardCode
  • 6,497
  • 4
  • 31
  • 54
  • You still have to provide the first part somehow, whether directly or by specifications. How can the method find it? Once you have that, it is a simple string concatenation. – Michael Foster Mar 29 '23 at 16:02
  • 1
    This question may help you find the root location for the share: https://stackoverflow.com/questions/64362116/c-sharp-find-local-directory-of-sharepoint-file (you're looking for the OneDrive provider) --- once you have that, you can use `System.IO.Path.Combine` to build the full path. – Craig Mar 29 '23 at 16:11

1 Answers1

-1

You need to work along the lines of something like this:

Dim MyPath As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Templates\Test Assembly\Test.txt")
video.baba
  • 817
  • 2
  • 6
  • 11