Quickest way is to reverse the string and look for the first occurrence.
DECLARE @StringA varchar(100), @pos int
SET @stringA = 'DirectoryA\DirectoryB\FileName'
-- Where is the last '\'?
SET @pos = LEN(@StringA) - CHARINDEX('\',REVERSE(@StringA))
SELECT @pos
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability