How To Change Extensions In VB.NET

In this tutorial i'm going to tell you how to change file extensions.
     Dim type As String = ".mp4"
        MsgBox(TextBox1.Text + " is changed into a " + type + " file.")
        Dim oldFile As String = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 4)
        FileCopy(TextBox1.Text, oldFile + type)
How to use it:
You have a form containing: 2 buttons, 1 textbox (or combobox)
When you click button one you can say it must open a openfiledialog:
Dim ofd As New Openfiledialog
If ofd.showdialog = dialogresult.OK then
TextBox1.Text = ofd.filename
End If
If we click the button, a openfiledialog will appear and we can choose a file name and if we click on 'ok', then the textbox will contain the filename of the openfiledialog.
Now double click on the other button and fill in the code above.
That's it!

Post a Comment

Note: Only a member of this blog may post a comment.