-1

Currently I have this path,

C:\Users\U6BRISON\Documents\DICOM Files\Trying.dcm

What I want to do is to just grab the last part: Trying.dcm

And edit it to a new file: [Clean]Trying.dcm

I believe I can use regex to do this but I'm not not sure if this is the best path forward. I want this to also be future proof so that I can identify any .dcm file and add the [Clean] tag to the front of the file.

maccettura
  • 10,514
  • 3
  • 28
  • 35

2 Answers2

2

Will this not suffice? System.IO.Path.GetFileName() method.

Emcrank
  • 310
  • 2
  • 12
1

Use:

Path.GetFileName( filePath );

It will pull the file name (with extension) from the path for you.

WBuck
  • 5,162
  • 2
  • 25
  • 36