Some issues with file extensions

Hello,

I’m working on a project that downloads attachments from a mailbox and renames them to the subject of the email. I’ve managed to make it work, but it overwrites the file extensions of the files.

Is there a function that can detect what extension the attachment has and record it to a variable so that I can add it after the subject? I could also do it with function that checks if the attachment has a given extension so that I can make my project work with the five extensions I need it to work with?

I’m open to other ideas as well, any help would be appreciated.

@dhristov You could use the Path class in System.IO. See the links below.

Dim p As String = "C:\Users\Me\Documents\Test.txt"
Dim extension As String = Path.GetExtension(p)
1 Like