How to get the folder name from the full path of folder?
This is file path,
"c:\projects\roott\wsdlproj\devlop\beta2\text"
Here text is the folder name.
But i want to get the folder containing text, that is beta2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
Path.GetDirectoryNamemethod can be used to return “c:\projects\roott\wsdlproj\devlop\beta2”, as shown below:To get just the name of the parent folder, “beta2”, you can split the input and take the second last entry, given that the input is indeed accurate: