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;
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.