Program that renames files

wardy484

New member
Joined
Dec 30, 2010
Messages
3
Programming Experience
1-3
I am trying to create a program that renames files to 1 - (however many files are in the folder) and also convert .pngs to .bmps, I had done this but I messed it up a little. I am not that experienced with VB.Net but I am looking to learn so any help would be great. I have tried this myself but as you can see in the code I've gone the wrong way about it. I'm clueless now to how to do this, any help would be appreciated :)

VB.NET:
        Dim fileNo As Integer

        If RadioButton1.Checked = True Then
            Dim files As String()
            files = IO.Directory.GetFiles(TextBox1.Text)
            Dim filepath_new As String

            filepath_new = TextBox1.Text

            For Each filepath As String In files
                For x = 0 To fileNo

                    My.Computer.FileSystem.RenameFile("*", x & ".bmp")
                    System.IO.File.Move(filepath, filepath_new)
                    x = x + 1
                Next x
            Next
 
Changing the extension on a file doesn't change what's in the file. Does slapping a label that says "Sugar" onto a jar of salt make the contents sugar? Certainly not, and this is the same: the extension is just a label to inform, but any file can have any extension. If you want to actually create a BMP format image from a PNG format image then you must open the file as an Image object by calling Image.FromFile, then call Save on that Image object and specify the new format.
 
Unfortuanatly I realised this not too long after posting but never got around to updating. I tried playing around with the function a litle but I couldn't figure out how to apply this to all the files in the folder.

Thank for the reply though :)
 
Back
Top