Jayesh Acharya
asked on
Path.GetDirectoryName(fpath) c#
I am using Path.GetDirectoryName(fpat
but what I want to do is just grab the directory from a particular sub direcorty onwards
and also grab the last directory
se using the example below I currently get :
dpath = Path.GetDirectoryName(fpat
gives me ...
"C:\\Users\\Documents\\Vis
but what I want is
1) from Projects onwards --
dpath1 = "\\MeasurLink7\\Mitutoyo.M
2 the last directory
dpath2 = "\\Mitutoyo.MeasurLink.Rea
any help would be appreciated
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
@the_o
There's nothing wrong with your proposal. My personal preference is to favor intuitive code for the benefit of those following behind me. Both solutions accomplish the same thing, but I believe what I posted is more evident in its intent. The difference is very negligible though.
I was just kidding you about the Substring() call = )
There's nothing wrong with your proposal. My personal preference is to favor intuitive code for the benefit of those following behind me. Both solutions accomplish the same thing, but I believe what I posted is more evident in its intent. The difference is very negligible though.
I was just kidding you about the Substring() call = )
While the_o's solution is feasilbe, I think you would benefit from the readability from using something like FileInfo class:
Open in new window