saedbfd saedbfd - 7 days ago 5x
C# Question

Get dynamic substring in c#

I have a string like this:


At the end of the string there is a file name (video name). the file name is not fixed and will change each time.

1 - How can i get file name (sad_3.mp4) in this string?

2 - After getting file name, how can i get file id? (file id comes after '_' and is 3 here)

  1. Path.GetFileName (MyPath)

  2. You want to probably use Regex to get a good match and extract the number.

Stackoverflow already has numerous similar questions and very good answers.

I encourage youe to expand ur search before asking.