0
You can use regular expression to get the file name. Here is an example: https://dotnetfiddle.net/DdzA3c
- using System;
- using System.Text.RegularExpressions;
-
- public class Program
- {
- public static void Main()
- {
- string file = @"C:\Users\xyz\Desktop\FYP\Animal\abc.jpg";
- string pattern = @"[ \w-]+?(?=\.)";
-
- Regex regex = new Regex(pattern);
-
- Match match = regex.Match(file);
-
- Console.WriteLine(match.Value);
- }
- }