Lanc1988 Posted August 28, 2005 Posted August 28, 2005 I have an image viewer that i coded into my program and it has a listbox that lists all the image files in a certain directory, for example: image001.bmp image002.jpg image003.png i also have a rename button so the user can rename the files but it isn't working that well, i think i coded the rename part pretty sloppy.. here is the code i used: Dim Rename As String Dim Picture As String Picture = ListBox1.Text 'Asks user for new name for picture Rename = InputBox("Type a new name for the picture and click Ok.") If Rename = "" Then Select Case Rename 'If rename is blank then give error Case "" MessageBox.Show("Image could not be renamed. Please try again.") End Select Else On Error Resume Next System.IO.File.Copy(Application.StartupPath & "\Sidekick Files\Image Viewer\" & Picture, Application.StartupPath & "\Sidekick Files\Image Viewer\" & Rename & ".bmp") System.IO.File.Delete(Application.StartupPath & "\Sidekick Files\Image Viewer\" & Picture) ListBox1.Items.Remove(Picture) ListBox1.Items.Add(Rename & ".bmp") 'Loads the Click a Image/Help page in browser. AxWebBrowser1.Navigate(Application.StartupPath & "\Sidekick Files\Click a Image.htm") MessageBox.Show("Image has been renamed to " & Rename & ".bmp") End If i couldnt figure out how to have it detect the current extention so i just put .bmp for it which doesnt work for any other image types. Quote
Administrators PlausiblyDamp Posted August 28, 2005 Administrators Posted August 28, 2005 If you want to manipulate paths then System.IO.Path takes care of a lot of the hard work. Also you could just use System.IO.File.Move if you wanted to rename a file. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Lanc1988 Posted August 29, 2005 Author Posted August 29, 2005 could you post an example of how i would use the system.io.file.move? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.