static void Main(string[] args) { string temp = @"c:TextDirtest.txt"; string test = temp.Substring((temp.LastIndexOf('\')),(temp.Length-temp.LastIndexOf('\'))); Console.WriteLine(test); }