Reducing File path to Folder level in C#

I am trying to get the file path of a loaded dxf/dwg. So far with some good help I have managed to get the file path. However I also want to get as an output the same path but to a folder level (same output but without the file name). How can I do that?


filepath.gh (8.3 KB)

Just use ?
fpath = System.IO.Path.GetDirectoryName(path);
https://docs.microsoft.com/fr-fr/dotnet/api/system.io.path.getdirectoryname?view=netframework-4.8

Yes! Magic! You save my ass way too many times today :smiley: I am guessing I am becoming kind of annoing :smiley: Should have learned to code years ago… Time to read all that documentation so I don’t bother people with basic stuff.
Can the same be done for the file path?

Not annoying, but don’t underestimate developpers from Microsoft, Rhinoceros … most of your problems occurs to others years ago and were solved. So it is good to search, what I did using c# + filepath

1 Like

Big issue for me is that I am totally code illiterate… And thats a huge handicap. So I do this so far just by trial and error and by asking people, then trying to understand the logic.

Like I find the page you send me, however I don’t get the syntax given there… To me it looks very different from what you just showed me how to do.

I also learn with trial and error. Learning coding is best by doing coding. It takes time. But internet is a GREAT help.

1 Like

It is actually great fun and I already see some learning curve, given the fact that I am fooling around with this for like 3 days. Maybe I should take some course and go trough a bucket of tutorials. I do enjoy this stuff :slight_smile: