File renaming and regular expressions

  • Thread starter Thread starter Brent
  • Start date Start date
B

Brent

Hmmm, could anyone recommend the best way, and if i'm lucky some code :) for
the following problem i have.

I have a file named:

xxxxxxxxxx.yyy i need to rename it to xxxxxxxxxxyyy.zzz

so basically strip the extension off, append it to the file name and add a
new extension..

any clues? thank you!
 
Try the Path Class

Example:

Imports System.IO

Dim test As String = "xxxxxxxxxx.yyy"
Dim ext As String
Dim filename As String

ext = Path.GetExtension(test)
filename = Path.GetFileNameWithoutExtension(test)

filename &= ext.Substring(1)
filename = Path.ChangeExtension(filename, ".zzz")
 
Back
Top