It bothered me now.
So i had to come up with a way to, but I would prolly choose the first one opver my own.
DECLARE @LastValue varchar(100)
declare @string varchar (100)
set @string = 'x:\folder1\folder2\folder3\test.txt'
SET @LastValue = ( CHARINDEX('\', REVERSE(@string)))
select SUBSTRING(@string,1, (LEN(@STRING) - CONVERT(INT,@LastValue))+1)