S
SimonH
Hi all,
I'm having problems identifying how to get the last directoy in a path string.
For example, in the Path 'C:\dir1\dir2\dir3'
I want to be able to get the name dir3
I've tried the following but for some reason it doesnt split the string at
all. It just returns the full string.
string[] splitPath = fullPath.Split('\\');
if(splitPath != null && splitPath.Length > 0){
dirName = splitPath[splitPath.Length - 1];
}
return dirName;
Ideally I'd also like to be able to identify the filename in a full path
string aswell, but I dont know how to do that either
Many thanks to anyone who could provide the magic incantations
Kindest Regards
Simon
I'm having problems identifying how to get the last directoy in a path string.
For example, in the Path 'C:\dir1\dir2\dir3'
I want to be able to get the name dir3
I've tried the following but for some reason it doesnt split the string at
all. It just returns the full string.
string[] splitPath = fullPath.Split('\\');
if(splitPath != null && splitPath.Length > 0){
dirName = splitPath[splitPath.Length - 1];
}
return dirName;
Ideally I'd also like to be able to identify the filename in a full path
string aswell, but I dont know how to do that either
Many thanks to anyone who could provide the magic incantations
Kindest Regards
Simon