saedbfd saedbfd - 1 year ago 117
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)

Answer Source
  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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download