I am trying to peel off the last part of a unc path that is being passed and put it in a variable to use in a method further down the line.
Example path would be --> \\ourfileserver\remoteuploads\countyfoldername\personfoldername
How do I peel just the countyfoldername
out of that?
I had thought to try
var th = e.FullPath.LastIndexOf('\\');
var whichFolder = folderPath.Substring(th);
but that is an escape character and it doesn't like @
either.
Is this even the right direction?
I think I have confused some of you. LastIndexOf
doesn't work because I need the countyfoldername
which, in my example, occurs 3/4 of the way through.
Also, I need the countyfoldername
stored in a variable, not the file name itself.
To give some context, I have a FileSystemWatcher
that runs in a service. It was monitoring a single folder path and emailing when a file was created there. Now I need to modify it. There are now 4 county folders at that folder path and I need to send an email to a different email address depending on where a file is created.
I can use a simple switch statement if I can figure out how to get the county folder name reliably.
Thanks