Saturday, February 4, 2012

C# get file name from file path

  String filePath = @"c:\file\neme\file.txt";

=> filePath.Split('\\')[filePath.Split('\\').Length-1]     ---->   Will give file name with extension

=> (filePath.Split('\\')[filePath.Split('\\').Length-1]).Split('.')[0] --> Will give file name without extension 


=> filePath.Split('\\')[0]  --> Will give drive letter 


No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

#Intel #Core #i9 #Processors: A Breakdown

Intel Core i9 Processors: A Breakdown Intel's 14th Gen Core i9 series offers a range of processors designed for various use cases. Her...