How to include the current user's path on a file?

377 views Asked by At

I have a file in a folder on a user's local drive. I want to reference it by just the last few folders, how do i do that? example:

string filePath = \\folder\file.txt; 
1

There are 1 answers

0
Seb On

Use "GetParent"

string path = Directory.GetCurrentDirectory(); //current path
string path1 = Directory.GetParent(path).ToString(); //parent of current path
string path2 = Directory.GetParent(path1).ToString(); //parent..
string path3 = Directory.GetParent(path2).ToString(); //parent..

Optimize it if you really want to use it. It just shows how it works.