How to get the full path to the file in c #? Suppose I have a file called "text.txt", which is located in the "Texts" folder on the desktop. I need to display its path in the format "C: / Users / User / folder name / folder name /".

  • one
    The question is unclear. And what information do you have on hand? - VladD
  • @VladD clear now? - Artem Zhiruev

1 answer 1

For your case, you first need to find out the path to the current user's Desktop. This is done like this:

var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); 

Having a way to Desktop, then it’s easy:

 var filePath = Path.Combine(desktopPath, "Texts", "text.txt");