I need to get the last part of current directory, for example from /Users/smcho/filegen_from_directory/AIRPassthrough
, I need to get AIRPassthrough
This is a slightly different answer, depending on what you have. If you have a list of files and need to get the name of the last directory that the file is in you can do this:
string path = "/attachments/1828_clientid/2938_parentid/somefiles.docx";
string result = new DirectoryInfo(path).Parent.Name;
This will return "2938_parentid"